RGLab / flowStats

flowStats: algorithms for flow cytometry data analysis using BioConductor tools
15 stars 10 forks source link

'list' object cannot be coerced to type 'integer' when using spillover() to calculate compensation matrix #44

Open jianwu1 opened 2 years ago

jianwu1 commented 2 years ago

Hi there,

Thank you very much for developing this package for analysing flow cytometry data! I've been trying to calculate compensation matrix with spillover() function using single stain controls, but have encountered this error that I can't resolve: I have a flowSet object called single_stain_A, and the sampleNames and colnames are as such:

Screen Shot 2022-02-22 at 7 52 57 pm

The code I used is standard: compA <- spillover(single_stain_A, unstained = 5, patt = "^[^FST]", fsc = "FSC.H", ssc = "SSC.H", stain_match = "regexpr")

But I get this error:

Screen Shot 2022-02-22 at 8 05 45 pm

Can I ask what the problem might be? What should I do to get the compensation matrix? The flowSet object single_stain_A is saved as a set of fcs files through write.flowSet(), and attached here.

Kind regards,

Jian single_stain_A.zip

jacobpwagner commented 2 years ago

The reason it's failing is because a few channels are matching multiple filenames in the regex check here. Specifically, "V610" will match "UV610" and "V610" and "V670" will match "UV670" and "V670" in your sampleNames because that regex check doesn't include any anchors. In your case, you can probably just force an exact match:

compA <- spillover(single_stain_A, unstained = 5, patt = "^[^FST]", fsc = "FSC.H", ssc = "SSC.H", stain_match = "regexpr", exact_match = TRUE)

@mikejiang, it might not hurt to add a shape/dimension check on that match to get a more helpful error. I'm happy to make a PR.

jianwu1 commented 2 years ago

a few channels are matching multiple filenames in the regex

@jacobpwagner I see! Thank you very much for providing me with such quick help!

jianwu1 commented 2 years ago

@jacobpwagner Hi Jake,

Although I'm now able to generate a spillover matrix from single_stain_A by setting exact_match = TRUE, the spillover matrix calculated by spillover() seems a bit wrong because the diagonal values are not 1:

Screen Shot 2022-02-27 at 12 32 12 am
jianwu1 commented 2 years ago

I found the solution in another thread using the spillover_ng function: https://github.com/RGLab/flowCore/issues/94#issuecomment-413938947

It gives a spillover matrix with diagonals being 1.