satijalab / sctransform

R package for modeling single cell UMI expression data using regularized negative binomial regression
GNU General Public License v3.0
203 stars 33 forks source link

Error running on cellbender adjusted counts #187

Open yesitsjess opened 3 months ago

yesitsjess commented 3 months ago

Hi,

I've run cellbender on my data and read the filtered count matrix into R using Read_CellBender_h5_Mat from scCustomize and then converted that to a Seurat object using CreateSeuratObject.

I'm getting to following error when I run SCTransform:

Running SCTransform on assay: RNA
Running SCTransform on layer: counts.01. Control 1 UTC
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Error in density.default(x = genes_log_gmean_step1, bw = "nrd", adjust = 1) : 
  'x' contains missing values

I've checked the cellranger documentation and the count data itself and they're integers so not log transformed. Lots of zero counts but there was before applying cellranger and SCTransform used to handle that fine.

Any help is appreciated. Thanks.

saketkc commented 3 months ago

What is the output of:

anyNA(object@assays$RNA@counts)
mdpatric commented 4 weeks ago

Was anyone able to find a solution to this?

yesitsjess commented 3 weeks ago

What is the output of:

anyNA(object@assays$RNA@counts)

This is FALSE for each layer and also FALSE if I join the layers I didn't find a solution - I'd still be interested in one

mdpatric commented 3 weeks ago

What is the output of:

anyNA(object@assays$RNA@counts)

This is FALSE for each layer and also FALSE if I join the layers I didn't find a solution - I'd still be interested in one

In some versions of cellbender 3.0.0 and 3.1.0 there is a bug that outputs negative values in the count matrix. Check for negative values in your output matrix. Sadly to fix this you will have to rerun cellbender on the master branch download or they have some proposed ways to recover messed up matrixes on the cellbender github if you have your checkpoint files.

yesitsjess commented 3 weeks ago

What is the output of:

anyNA(object@assays$RNA@counts)

This is FALSE for each layer and also FALSE if I join the layers I didn't find a solution - I'd still be interested in one

In some versions of cellbender 3.0.0 and 3.1.0 there is a bug that outputs negative values in the count matrix. Check for negative values in your output matrix. Sadly to fix this you will have to rerun cellbender on the master branch download or they have some proposed ways to recover messed up matrixes on the cellbender github if you have your checkpoint files.

Ok yes I have negative values - thanks for the pointer! I'll try rerunning it with a new version of cellbender (urghhh, it takes ages). Thanks again.

EDIT: there's a command in README to allow just a partial rerun and salvage v0.3.1 https://github.com/broadinstitute/CellBender/blob/master/README.rst