HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 31 forks source link

Loss of channels in the SingleCellExperiment - Function prepData #151

Closed PaulineMaby closed 4 years ago

PaulineMaby commented 4 years ago

Hello, Here are more details about the problem I experienced with the function prepData. The fcs files that I imported in the flowset (with the fuction fs <- read.flowSet(path= original.file.folder, transformation=FALSE, truncate_max_range = FALSE)), contain 36 marker channels (CD3, CD4…) and a channel named « cluster » that is a spade cluster that I would lke to keep for the UMAP visualisation. This « cluster » channel is kept in the fs, as shown by:

fs@frames[["03n2.fcs"]]@description[["$P39S"]] $*P395 character (1) ‘cluster’

This « cluster » channel is in the panel.xslx file that I used to create a SingleCellExperiment with the fonction sce <- prepData(fs, panel, md, features = panel$fcs_colname)

However, even if this « cluster » channel is present within features = panel$fcs_colname, when I create a SingleCellExperiment from this fs (with prepData), only the 36 marker channels are kept and the « cluster » channel is lost, as shown by:

scetest@int_elementMetadata@rownames nrows integer(1) 36

I wonder how to avoid this channel loss, in order to be able to map some of the spade clusters on the UMAP plot ?

HelenaLC commented 4 years ago

The reason the cluster appears to have been dropped is because prepData, by default, checks for non-mass channels and moves them to the int_colData() of the output SCE. The reasoning behind this is that all assay data may be subject to data manipulation / computation, e.g., computing quantiles, means, transformations etc. - and this should not happen on categorical variables (e.g. sample IDs, cluster assignments), but only measurement variables (i.e. actual markers).

To retrieve the cluster labels, you can simply extract them from the int_colData and store them in the colData via sce$spade <- int_colData(sce$cluster). Then, you will be able to color by this variable in all plotting functions (e.g. plotDR(sce, color_by = "spade")).

PaulineMaby commented 4 years ago

Thank you very much for your extremely prompt answer, it was super helpful, it is sincerely appreciated ! Also I wanted to thank you very much for the CATALYST workflow, it is really great for non bioinformaticien immunologist struggling with R! The issue is closed on Github, so I answer here.

In my environment, the line that you’ve sent to create a “spade” parameter within the sce/colData did not work:

sce$spadetest1 <- int_colData(sce$cluster)

Error in (function (classes, fdef, mtable) :

unable to find an inherited method for function ‘int_colData’ for signature ‘"NULL"’

Therefore, to add a “spade” parameter to the sce/colData, I used this line instead:

sce@colData@listData[["Spade_cluster"]] <- factor(sce@int_colData @listData[["cluster"]])

I wanted to let you know in case it could help others having the same trouble as me.

Also I have another related question and I hope I am not bothering you asking it here. I would be extremely grateful if you could help me using the mergeClusters function on these spade clusters.

The k parameter of this function has to be names(cluster_codes(x)), so (if I understood correctly) "som100"or "meta20". In order to have the spade clusters into cluster_codes I tried this line:

sce@metadata[["cluster_codes"]][["spade200"]] <- sce@colData @listData[["Spade_cluster"]]

Error in [[<-.data.frame(*tmp*, "spade200", value = c(17L, 110L, 150L, :

replacement has 811774 rows, data has 100

I also tried to get spade spade clusters into cluster_codes without running the FlowSOM and ConsensusClusterPlus (even though it is not what I want to do), but neither did it work:

sce@metadata[["cluster_codes"]][["spade200"]] <- sce@colData @listData[["Spade_cluster"]]

sce <- mergeClusters(sce, k = "spade200", table = merging_table1, id = "merging1")

Error in .check_sce(x, TRUE) : !is.null(x$cluster_id) is not TRUE

So I was wondering if there is any way to use previous clustering methods with the CATALYST workflow?

I thank you very much for your time.

Best regards,

Pauline Maby

Le ven. 9 oct. 2020 à 17:04, Helena L. Crowell notifications@github.com a écrit :

Closed #151 https://github.com/HelenaLC/CATALYST/issues/151.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HelenaLC/CATALYST/issues/151#event-3860594433, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKWNM2OK3C2WB7CE5F42WLSJ4Q6ZANCNFSM4SKFT66A .

-- Pauline Maby, Ph.D. Postdoctoral Research Associate in Tumor Immunology INSERM UMRS1138, Integrative Cancer Immunology Cordeliers Research Center 15 Rue de l'Ecole de Medecine 75006 Paris, France

Office: +33 1 4427 9096 Fax: +33 1 4427 8117 Mobile France: +33 6 9803 2544 mabypau@gmail.com