HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 30 forks source link

`prepData()` unexpectedly create "exprs" if doing manual transformation using FlowJo for FACS? #356

Closed denvercal1234GitHub closed 1 year ago

denvercal1234GitHub commented 1 year ago

Hi there,

I transformed my FACS data in FlowJo with bi-exponential transformation and exported the data as channel values (.csv) so the transformation was preserved.

In order to get the FCS files but with transformed data, I then read in the channel values (.csv) into R using Spectre::read.files, then exported the files out as FCS using Spectre::write.files. These exported FCS files are now transformed.

I then used flowCore::read.flowSet to read in the transformed FCS files as a flowSet settingtransformation = FALSE, before performing prepData.

F37_channel_data.list <- Spectre::read.files(file.loc = "/Users/stillhere/Documents/.../F37_FlowJoBiExED_ChannelValues", file.type = ".csv", do.embed.file.names = TRUE)

Spectre::write.files(F37_channel_data.list_cell.dat, write.csv = FALSE, write.fcs = TRUE, file.prefix = "channelFCS", divide.by = "FileName") 

F37_channel_fcs_data <-flowCore:: read.flowSet(path=fcs.dir1, pattern="*.fcs", transformation = FALSE, truncate_max_range = FALSE) 

F37_channel_fcs_data_sce <- prepData(x=F37_channel_fcs_data, transformation = F, truncate_max_range=F, FACS=T ... )`

However, when I ran assayNames(F37_channel_fcs_data_sce), it already had counts and exprs assays, without me doing assayNames(sce) <- “exprs” as suggested in #122

The output of CATALYST::plotScatter(F37_channel_fcs_data_sce, c("CD183", "CD185"), assay = "counts") looks like this:

Screenshot 2023-07-20 at 22 38 40

The output of CATALYST::plotScatter(F37_channel_fcs_data_sce, c("CD183", "CD185"), assay = "exprs") looks like this:

Screenshot 2023-07-20 at 22 39 25

Would you mind letting me know which assay I should use for the clustering from here? Because the exprs does not look right (all the cells have expression at 5 and no cells have 0 expression), whereas it looks like counts is actually what I expect to use for downstream clustering.

In fact, if I proceed with the clustering with default parameters (i.e., using exprs assay), all markers across clusters are expressed at around 5 as the baseline.

Screenshot 2023-07-20 at 22 56 13

Thank you very much for your help!

HelenaLC commented 1 year ago

CATALYST doesn’t know you’re data has already been transformed, so it’ll apply an arcsinh transformation by default. You can turn this off by setting transformation=FALSE in prepData() (& rename the - what should then be the one and only - assay to “exprs” as suggested above); see also the function documentation.

denvercal1234GitHub commented 1 year ago

Hi @helenaLC - thank you for the response. But the issue was unfortunately even when I set transformation = F in ‘prepData’, it still produces exprs assay slot as shown in the code above.

HelenaLC commented 1 year ago

Should be transform=FALSE, my mistake… but again: please see the function documentation 🙏