FAQ  •  Register  •  Login

Problems with Cytof workflow (Nowicka et al)

Forum rules
Please be as geeky as possible. Reference, reference, reference.
Also, please note that this is a mixed bag of math-gurus and mathematically challenged, so choose your words wisely :-)
<<

nkhanbham

Master

Posts: 53

Joined: Wed Feb 25, 2015 3:03 pm

Post Wed Aug 01, 2018 2:15 pm

Problems with Cytof workflow (Nowicka et al)

I have been trying out the CyTOF workflow pipeline published by Nowicka et al. It seems to work fine with flow cytometry data files for me but not with my own CyTOF (Helios) derived fcs files (which work fine in other R based pipelines like Cytofkit).
The problem I have is at the FlowSom cell identification stage - I get an error saying that the antigen (141Pr_CD45 etc) columns cannot be found. From some checking of the data structure (in R) it appears that there is a conflict due to an X at the front of each channel (141Pr_CD45 and X141Pr_CD45). I am not sure where the X has come from, but adding an X to my channel labels in the panel.xls file does not solve the problem. This error also appears with all the later analyses in the pipeline.
Anyone have ideas of what is possibly going on? I am wondering whether it is something written in the CyTOF FCS file metadata.
Naeem
<<

sgranjeaud

Master

Posts: 123

Joined: Wed Dec 21, 2016 9:22 pm

Location: Marseille, France

Post Wed Aug 01, 2018 2:28 pm

Re: Problems with Cytof workflow (Nowicka et al)

Hi,
I don't have a solution, but X are added by R because the name of the variables should not start by a number. Could you paste the exact command and output ?
Best.
<<

nkhanbham

Master

Posts: 53

Joined: Wed Feb 25, 2015 3:03 pm

Post Wed Aug 01, 2018 2:46 pm

Re: Problems with Cytof workflow (Nowicka et al)

This is the code I run - taken from Nowicka paper. I actually got it to work with the CyTOF data set they used in the paper (Robinson PBMC data) without the errors I get with my own data.


> library(FlowSOM)
> fsom <- ReadInput(fcs, transform = FALSE, scale = FALSE)
> set.seed(1234)
> som <- BuildSOM(fsom, colsToUse = lineage_markers)
Building SOM

Mapping data to SOM

> ## Get the cell clustering into 100 SOM codes
> cell_clustering_som <- som$map$mapping[,1]
>
> ## Metaclustering into 20 clusters with ConsensusClusterPlus
> ## Including choosing random seed so if repeated gives same data
> library(ConsensusClusterPlus)
>
> codes <- som$map$codes
> plot_outdir <- "consensus_plots"
> nmc <- 20
>
> mc <- ConsensusClusterPlus(t(codes), maxK = nmc, reps = 100,
+ pItem = 0.9, pFeature = 1, title = plot_outdir, plot = "png",
+ clusterAlg = "hc", innerLinkage = "average", finalLinkage = "average",
+ distance = "euclidean", seed = 1234)
end fraction
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
clustered
>
> ## Get cluster ids for each cell
> code_clustering1 <- mc[[nmc]]$consensusClass
> cell_clustering1 <- code_clustering1[cell_clustering_som]
>
> ## Heatmap
> # Define cluster colors (here there are 30 colors)
> color_clusters <- c("#DC050C", "#FB8072", "#1965B0", "#7BAFDE", "#882E72",
+ "#B17BA6", "#FF7F00", "#FDB462", "#E7298A", "#E78AC3",
+ "#33A02C", "#B2DF8A", "#55A1B1", "#8DD3C7", "#A6761D",
+ "#E6AB02", "#7570B3", "#BEAED4", "#666666", "#999999",
+ "#aa8282", "#d4b7b7", "#8600bf", "#ba5ce3", "#808000",
+ "#aeae5c", "#1e90ff", "#00bfff", "#56ff0d", "#ffff00")
>
> ## Generate graphics - Heatmap of the median marker intensities of the 10 lineage markers across the 20 cell populations obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus
>
> plot_clustering_heatmap_wrapper <- function(expr, expr01,
+ cell_clustering, color_clusters, cluster_merging = NULL){
+
+ # Calculate the median expression
+ expr_median <- data.frame(expr, cell_clustering = cell_clustering) %>%
+ group_by(cell_clustering) %>% summarize_all(funs(median))
+ expr01_median <- data.frame(expr01, cell_clustering = cell_clustering) %>%
+ group_by(cell_clustering) %>% summarize_all(funs(median))
+
+ # Calculate cluster frequencies
+ clustering_table <- as.numeric(table(cell_clustering))
+ clustering_prop <- round(clustering_table / sum(clustering_table) * 100, 2)
+
+ # Sort the cell clusters with hierarchical clustering
+ d <- dist(expr_median[, colnames(expr)], method = "euclidean")
+ cluster_rows <- hclust(d, method = "average")
+
+ expr_heat <- as.matrix(expr01_median[, colnames(expr01)])
+ rownames(expr_heat) <- expr01_median$cell_clustering
+
+ # Colors for the heatmap
+ color_heat <- colorRampPalette(rev(brewer.pal(n = 9, name = "RdYlBu")))(100)
+ legend_breaks = seq(from = 0, to = 1, by = 0.2)
+ labels_row <- paste0(expr01_median$cell_clustering, " (", clustering_prop ,
+ "%)")
+
+ # Annotation for the original clusters
+ annotation_row <- data.frame(Cluster = factor(expr01_median$cell_clustering))
+ rownames(annotation_row) <- rownames(expr_heat)
+ color_clusters1 <- color_clusters[1:nlevels(annotation_row$Cluster)]
+ names(color_clusters1) <- levels(annotation_row$Cluster)
+ annotation_colors <- list(Cluster = color_clusters1)
+ # Annotation for the merged clusters
+ if(!is.null(cluster_merging)){
+ cluster_merging$new_cluster <- factor(cluster_merging$new_cluster)
+ annotation_row$Cluster_merging <- cluster_merging$new_cluster
+ color_clusters2 <- color_clusters[1:nlevels(cluster_merging$new_cluster)]
+ names(color_clusters2) <- levels(cluster_merging$new_cluster)
+ annotation_colors$Cluster_merging <- color_clusters2
+ }
+
+ pheatmap(expr_heat, color = color_heat, cluster_cols = FALSE,
+ cluster_rows = cluster_rows, labels_row = labels_row,
+ display_numbers = FALSE, number_color = "black",
+ fontsize = 8, fontsize_number = 6, legend_breaks = legend_breaks,
+ annotation_row = annotation_row, annotation_colors = annotation_colors)
+
+ }
>
> plot_clustering_heatmap_wrapper(expr = expr[, lineage_markers_ord],
+ expr01 = expr01[, lineage_markers_ord],
+ cell_clustering = cell_clustering1, color_clusters = color_clusters)
Show Traceback

Rerun with Debug
Error: Columns `159Tb_CD13`, `141Pr_CD45`, `153Eu_CD2`, `154Sm_CD3`, `148Nd_CD34`, `155Gd_CD45RA`, `158Gd_CD33`, not found >
<<

sgranjeaud

Master

Posts: 123

Joined: Wed Dec 21, 2016 9:22 pm

Location: Marseille, France

Post Wed Aug 01, 2018 3:21 pm

Re: Problems with Cytof workflow (Nowicka et al)

IMHO you should check your panel variable (that was read from the Excel file you set up). I suspect that you named your marker in a way that is not understood from R. Check the antigen column. If you check the data frame of Nowicka et al it looks like the following. I think you should change your naming convention so that 159Tb_CD13 becomes CD13_159Tb in order to avoid any variable starting with a number. Change Excel file and rerun from the "read panel" step.
Hope this help.
  Code:
> panel
   Metal Isotope Antigen Lineage Functional
1     Cd 110:114     CD3       1          0
2     In     115    CD45       1          0
3     La     139     BC1       0          0
4     Pr     141     BC2       0          0
5     Nd     142   pNFkB       0          1
6     Nd     144    pp38       0          1
7     Nd     145     CD4       1          0
8     Nd     146     BC3       0          0
<<

markrobinsonca

Participant

Posts: 11

Joined: Wed Apr 19, 2017 7:35 pm

Post Sat Aug 04, 2018 3:21 pm

Re: Problems with Cytof workflow (Nowicka et al)

A couple quick thoughts:

1. From the message above, I haven't been able to exactly locate the problem. Could you perhaps enumerate through all the input arguments to the wrapper function:

lineage_markers_ord
expr[, lineage_markers_ord]
expr01[, lineage_markers_ord]
cell_clustering1
color_clusters

.. and see which one has the problem? .. and then try to fix.

2. In the 1.4.x series of CATALYST (http://bioconductor.org/packages/releas ... ALYST.html), we (i.e., Helena) have now streamlined the vast majority of the workflow via `daFrame` objects. You can see more details here:

http://bioconductor.org/packages/releas ... lysis.html

I don't know if that solves the problem as there is still some matching required, but most of the steps of the workflow are represented there. The idea would be to make a v3 of F1000 article with the streamlined code. We have done part of this, but it is not finished yet and we hope to do this in the next few months.

Hope that helps, Mark
<<

nkhanbham

Master

Posts: 53

Joined: Wed Feb 25, 2015 3:03 pm

Post Wed Aug 08, 2018 7:26 pm

Re: Problems with Cytof workflow (Nowicka et al)

Thanks Mark. I will try out what you have suggested.
Naeem
<<

albertapaul

Participant

Posts: 7

Joined: Tue Oct 30, 2018 4:30 am

Post Thu Nov 01, 2018 10:21 pm

Re: Problems with Cytof workflow (Nowicka et al)

HI I am new to this forum but want to use Cytofkit for spectral flow data (Aurora) of 24-25 parameters with 22 potentially co-expressed on CD4 T cells.
Panel is on cultured human PBMC stimulated for 1 week with antigens
Just wonder which scaling to use when importing, many channels have significant spreading into the negative (especially with autofluorescence subtraction).
Let me know.
<<

TomCyToF

Participant

Posts: 4

Joined: Mon Jul 23, 2018 2:58 pm

Post Thu Nov 22, 2018 4:48 pm

Re: Problems with Cytof workflow (Nowicka et al)

Hi,

I have run into the same issue, I think the problem is the stain (or antigen) name in my fcs files. They currently have a number at the start (as below)

> head(data.frame(panel))
Metal Isotope Antigen Singlets T T_helper
1 Y 89 89Y_CD45 1 0 0
2 Cd 113 113In_Cd19 1 0 0
3 Pr 141 141Pr_CD196 0 1 1
4 Nd 142 142Nd_CTLA4 0 1 1
5 Nd 143 143Nd_TCR_Gd 1 1 1
6 Nd 144 144Nd_CD3 1 0 0

Can anyone help me with a simple way to change multiple fcs files so that the column header has a letter not a number (such as CD45 instead of 89Y_CD45)?
I can do this on individual files in FCS Express but will take a long time to do on every fcs file.

Thanks

Tom
<<

markrobinsonca

Participant

Posts: 11

Joined: Wed Apr 19, 2017 7:35 pm

Post Thu Nov 22, 2018 6:51 pm

Re: Problems with Cytof workflow (Nowicka et al)

TomCyToF wrote:Hi,

I have run into the same issue, I think the problem is the stain (or antigen) name in my fcs files. They currently have a number at the start (as below)

> head(data.frame(panel))
Metal Isotope Antigen Singlets T T_helper
1 Y 89 89Y_CD45 1 0 0
2 Cd 113 113In_Cd19 1 0 0
3 Pr 141 141Pr_CD196 0 1 1
4 Nd 142 142Nd_CTLA4 0 1 1
5 Nd 143 143Nd_TCR_Gd 1 1 1
6 Nd 144 144Nd_CD3 1 0 0

Can anyone help me with a simple way to change multiple fcs files so that the column header has a letter not a number (such as CD45 instead of 89Y_CD45)?
I can do this on individual files in FCS Express but will take a long time to do on every fcs file.

Thanks

Tom


Tom: do you need to change it only on the R side (after reading in a FCS file), or in the FCS file itself? The latter is a bit harder, but here is some R code to do the parsing of the strings, in case that helps:

panel$Antigen_clean <- sapply(strsplit(as.character(panel$Antigen),"_"), .subset, 2)

If you need to do this on the FCS files, you'd need to write some kind of loop, use foo <- read.FCS("my.fcs") to read each file into a 'flowFrame', then make modifications to parameters(foo)$name (like above) and then use write.FCS() to write a new file. Possibly there are more elegant solutions around.

Mark
<<

ghowell

Participant

Posts: 19

Joined: Wed Nov 26, 2014 3:18 pm

Post Fri Nov 23, 2018 11:53 am

Re: Problems with Cytof workflow (Nowicka et al)

Hi Tom,

I recently started using the premessa package https://github.com/ParkerICI/premessa for cleaning up some data.
Its got a lot of fcs tool and I don't know if it'll do what you need but might be worth a look.
Or maybe the flow cytometry suite on GenePattern has a suitable tool http://software.broadinstitute.org/canc ... etry-suite
I've not dabbled there as yet!

Gareth
Next

Return to CyTOF data analysis

Who is online

Users browsing this forum: No registered users and 12 guests