cnio-bu / beyondcell

Beyondcell is a computational methodology for identifying tumour cell subpopulations with distinct drug responses in single-cell RNA-seq and Spatial Transcriptomics data.
Other
40 stars 4 forks source link

Error in bcRanks #120

Closed mj-jimenez closed 1 year ago

mj-jimenez commented 1 year ago

bcRanks returns the following error:

Error in quantile.default(as.numeric(out$residuals.mean), prob = seq(from = 0,  : 
  missing values and NaN's not allowed if 'na.rm' is FALSE

I think it is due to bad cell subsetting.

mj-jimenez commented 1 year ago

Actually, it is due to all cells in a cluster having NaN values for a signature. To solve this there are several approaches:

SGMartin commented 1 year ago

Any news on this front @mj-jimenez ?

mj-jimenez commented 1 year ago

This error appears in bcRanks but it is caused by the NaN values introduced when creating the beyondcell object. As said in #113, the best practice right now is this work-around until we update the bcScore function:

# Beyondcell object with a lot of NaN values
bcobj <- bcScore(sc, SSc, expr.thres = 0.1)

# Filter out spots with a high percentage of NAs                                                                                                                                                                                       
bcobj.filtered <- bcSubset(bcobj, nan.cells = 0.95)                                                                                                                                                                                    

# Replace NAs by 0s                                                                                                                                                                                                                    
bcobj.filtered@normalized[is.na(bcobj.filtered@normalized)] <- 0                                                                                                                                                                       
bcobj.recomputed <- bcRecompute(bcobj.filtered, slot = "normalized") 
mj-jimenez commented 1 year ago

Also, this problem is signature related (i.e. most of the genes in the signatures are not found in the expression matrix). This happened in beyondcell v2.0, which contained a high proportion of non-coding genes. Since beyondcell v2.1, the signatures only contain coding genes, thus this error is unlikely to happen with a standard single-cell experiment.