satijalab / sctransform

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

sctransform batch_var error #110

Open lo2811 opened 3 years ago

lo2811 commented 3 years ago

Hi Christoph,

I am running SCTransform with batch_var and encounter this error: "Error in while ((it <- it + 1) < limit && abs(del) > eps) { : missing value where TRUE/FALSE needed". Here is the full error:

epi <- SCTransform(epi, batch_var="dataset") Calculating cell attributes from input UMI matrix: log_umi Variance stabilizing transformation of count matrix of size 47902 by 150006 Model formula is y ~ (log_umi) : dataset + dataset + 0 Get Negative Binomial regression parameters per gene Using 2000 genes, 5000 cells | | 0% warning: solve(): system is singular; attempting approx solution |============================ | 25% warning: solve(): system is singular; attempting approx solution Error in while ((it <- it + 1) < limit && abs(del) > eps) { : missing value where TRUE/FALSE needed

I was able to use this same code to run on the same object in April/May this year. Now I need to regenerate the Seurat object and run into this error. I'm using the development sctransform, just reinstalled it on my machine this week using: remotes::install_github("ChristophH/sctransform@develop").

The error goes away if I increase the n_cells to 10,000, but I would prefer to keep everything consistent with the previous times (n_cells=5000). It is strange that I have this error now, since I'm running the exact same code on the same samples.

Thank you! Linh

ChristophH commented 3 years ago

Are you using the same version of Seurat as before? That could also be a reason why the same code is not working anymore.

In any case, without a reproducible example I cannot say what the problem is exactly. If you are sure changes in the sctransform package are the cause, you can also try to install an older version, i.e. a specific commit. For example remotes::install_github("ChristophH/sctransform@73e2e3e") would install the develop version as of 30. March 2021

Other commits to the develop branch are listed here

Another option is to change the parameter estimation method that sctransform is using. E.g.

if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager")
BiocManager::install("glmGamPoi")
epi <- SCTransform(epi, batch_var="dataset", method = "glmGamPoi")
lo2811 commented 3 years ago

Thank you Christoph. I tried glmGamPoi before and it worked, but will try installing the specific sctransform and Seurat version as well.