how to use the flowCore spillover function
Entering edit mode
Last seen 4.6 years ago

Hi, i have been trying to convert a gatingset to a flowJO workspace object by using the gatingset2FlowJO function from cytoML. After some experimentation i succeeded. However i noticed that only my transformation was in the flowJO workspace and not the compensation. The problem seems to be that i do have a Compensation slot in the gatingset but the compensation itself has no spillover information. Which is correct since we usually only apply a compensation matrix with the compensate function to NCDFflowset.

To try and get the spillover information into the NCDFflowset or gatingset i attempted the following:

fcsFiles <-dir(path = "C:/AmazonSWAP/Compensation/ICS-19-00011",pattern = ".fcs",full.names = T)
fcs  <- read.ncdfFlowSet(fcsFiles, alter.names = T)
spillover <- spillover(fcs , unstained = 17 , fcs = c("FCS.A", "FCS.H", "FCS.W") , ssc = c("SSC.A", "SSC.H" , "SSC.W") , useNormFilt = TRUE )

But this gives me the error:

Error: Could not find forward scatter parameter. Please set the fsc parameter

I have the following files for a 16 color panel (16 compensation controls on beads with an unstained cells sample)

> fcsFiles
 [1] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_alexa fluor 700 stained control_b03_118.fcs"
 [2] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_apc-cy7 stained control_b04_119.fcs"        
 [3] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_apc stained control_a11_114.fcs"            
 [4] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_buv395 stained control_a05_108.fcs"         
 [5] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_buv737 stained control_a06_109.fcs"         
 [6] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_bv421 stained control_a08_111.fcs"          
 [7] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_bv510 stained control_a01_104.fcs"          
 [8] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_bv605 stained control_a02_105.fcs"          
 [9] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_bv650 stained control_a09_112.fcs"          
[10] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_bv711 stained control_a12_115.fcs"          
[11] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_bv786 stained control_a04_107.fcs"          
[12] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_fitc stained control_a07_110.fcs"           
[13] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_pe-cy5 stained control_a03_106.fcs"         
[14] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_pe-cy7 stained control_a10_113.fcs"         
[15] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_pe-texas red stained control_b02_117.fcs"   
[16] "C:/AmazonSWAP/Compensation/ICS-19-00011/compensation controls_pe stained control_b01_116.fcs"             
[17] "C:/AmazonSWAP/Compensation/ICS-19-00011/unstained cells_h12_h12_103.fcs"

The file structure is as followed:

> fcs
An ncdfFlowSet with 17 samples.
NCDF file : C:\Users\kteijgel\AppData\Local\Temp\Rtmpeqsz1r\ 
An object of class 'AnnotatedDataFrame'
  rowNames: compensation controls_alexa fluor 700 stained control_b03_118.fcs compensation
    controls_apc-cy7 stained control_b04_119.fcs ... unstained cells_h12_h12_103.fcs (17 total)
  varLabels: name
  varMetadata: labelDescription

  column names:
    Time, FSC.A, FSC.H, FSC.W, SSC.A, SSC.H, SSC.W, FITC.A, APC.A, Alexa.Fluor.700.A, APC.Cy7.A, BV421.A, BV510.A, BV605.A, BV650.A, BV711.A, BV786.A, BUV395.A, BUV737.A, PE.A, PE.Texas.Red.A, PE.Cy5.A, PE.Cy7.A

The FCS files are also accesible here:

What am i doing wrong?:) Please tell me if you need more information.

flowCore spillover gatingset2FlowJO • 1.6k views
Entering edit mode
Jake Wagner ▴ 310
Last seen 3.4 years ago

There are a few different issues at play here. First, your error is coming about from a simple typo. The argument to specify the forward scatter parameter is fsc, not fcs. Second, you can only specify a single column name for each scatter parameter, not a vector of names. That is, you have this:

... fcs = c("FCS.A", "FCS.H", "FCS.W"), ssc = c("SSC.A", "SSC.H" , "SSC.W") ...

when you need this

... fsc = "FCS.A", ssc = "SSC.A" ...

After those fixes, however, you will need to deal with the fact that you will have more columns than control files (because "FSC.H", "FSC.W", "SSC.H", and "SSC.W" will be treated as normal channels). One way to do this is to use the patt argument to spillover to specify the columns relevant for calculating the spillover matrix:


So the updated spillover call would be:

spillover <- spillover(fcs , unstained = 17 , fsc ="FSC.A" , ssc ="SSC.A" , useNormFilt = TRUE, patt="FSC.A|SSC.A|BV|PE|Alexa|BUV|APC|FITC")

However, now there is another issue. The method needs a way to match channels to control files. By default, this is done by assigning each file as the control for the channel for which it has the greatest median intensity. In your case, you will get an error because one of your controls (APC-Cy7 I think) has a low median intensity in that channel, so the match will be ambiguous. You can manually match files using spillover_match, but if you change the statistic to mean it should complete succesfully. So try this:

spillover <- spillover(fcs , unstained = 17 , fsc ="FSC.A" , ssc ="SSC.A" , useNormFilt = TRUE, patt="FSC.A|SSC.A|BV|PE|Alexa|BUV|APC|FITC", method="mean")

Additionally, I recently moved spillover to flowStats along with norm2Filter and made a few other fixes. These changes will be moved to bioconductor soon, but otherwise you can pull them from the GitHub repos:

Entering edit mode

Thanks a lot for the thorough explanation and quick response Jake, and also for correcting my typo!

spillover <- spillover(fcs , unstained = 17 , fsc ="FSC.A" , ssc ="SSC.A" , useNormFilt = TRUE, patt="FSC.A|SSC.A|BV|PE|Alexa|BUV|APC|FITC", method="mean")

This one works for me :)

Entering edit mode

No problem. Thanks for including the files and code. It makes troubleshooting so much easier.


Login before adding your answer.

Traffic: 403 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6