SofieVG / FlowSOM

Using self-organizing maps for visualization and interpretation of cytometry data
61 stars 26 forks source link

Error while using GetFeatures to map files #60

Closed maiabennett closed 1 year ago

maiabennett commented 1 year ago

Hello,

I am trying to apply FlowSOM to my data but am running into an error (below) when using the GetFeatures function to add a compensated flowSet of eight .fcs files. When I attempt to run GetFeatures on a single flowFrame, the same error is encountered. I have also attempted to add the files using a vector of their locations and names, again encountering the same error. I am unsure how to address this.

Thank you in advance for your time!

flowSOM.untreated.res <- FlowSOM(baseline.untreated, scale = TRUE)
untreatedset <- read.flowSet(path = "C:/Users/Me/Documents/FUSE 2023/PhenoData/Untreated")
untreatedset <- compensate(untreatedset, comp)
percentages <-GetFeatures(fsom = flowSOM.untreated.res,
                                             files = c(untreatedset),
                                             type = "percentages")
Mapping file 1 of 1.
Scaling the data
Error in newdata[, colnames(codes)] : subscript out of bounds
SamGG commented 1 year ago

Hi, IIUC, you are trying to map a set of 8 FCS to an already computed FlowSOM result. To do so, the 8 FCS must be mapped to the FlowSOM result. Read the following and the overall step-by-step pipeline which is awesome. Best. https://github.com/saeyslab/FlowSOM_protocol/blob/d2fbbfe595baf6996be8966b3f7279f7413151fe/R/FlowSOM_protocol.R#L460-L471

maiabennett commented 1 year ago

Hi,

To clarify, the FlowSOM object I am using is constructed of a concatenated .FCS file of the 8 individual files. I am attempting to run an analysis following part 9, 'Comparing different groups', of the FlowSOM vignette. I do not want to create a new FlowSOM result, but to compare the differential percentages of clusters present between two treatment groups. I have read through the code you have provided as well as the R package documentation and do not believe the highlighted NewData function is applicable, as it does not return the necessary percentages matrix. Do you have any further suggestions? I do agree that your pipeline is very good.

SamGG commented 1 year ago

This pipeline is from @KatrienQ, one of the developer of FlowSOM, not me. The dev will help you better than me.

SofieVG commented 1 year ago

Can you just confirm what the column names from your original training data were (e.g. by colnames(flowSOM.untreated.res)) and what the column names from your new data are (e.g.colnames(untreatedset[[1]]) )? I am thinking maybe you aggregated files in your baseline.untreated and might have some additional columns there, not present in your untreatedset ? If it is a concatenated file with e.g. a SampleID or File column, you might want to specify the colsToUse parameter in FlowSOM to make sure those columns are not used for clustering.

maiabennett commented 1 year ago

@SofieVG, thank you! I was able to trace back the error source. It was due to differences in parameters between the concatenated file and its component individual files. Thanks again for your time!