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

Error in umi@x: no applicable method for `@` applied to an object of class "matrix" #172

Closed ceesu closed 12 months ago

ceesu commented 1 year ago

I got the exact same error as #170 when running sctransform v2 on some Seurat objects. I don't know if it might be connected to size of counts in the file object because it seems to only happen for datasets where large counts are not filtered out.

The data I used is from the .layers['counts'] slot of "Immune_ALL_human.h5ad" from this public dataset collection:

Here is the code that gave me the error.

data <- SCTransform(data, vst.flavor = "v2", 
                      method = "glmGamPoi", 
                      return.only.var.genes = FALSE, 
                      verbose = TRUE, min_cells = 0)

This is the output:

vst.flavor='v2' set, setting model to use fixed slope and exclude poisson genes.
Calculating cell attributes from input UMI matrix: log_umi
Total Step 1 genes: 12303
Total overdispersed genes: 12303
Excluding 0 genes from Step 1 because they are not overdispersed.
Variance stabilizing transformation of count matrix of size 12303 by 33506
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 5000 cells
  |==================================================================================| 100%
Setting estimate of  12 genes to inf as theta_mm/theta_mle < 1e-3
# of step1 poisson genes (variance < mean): 0
# of low mean genes (mean < 0.001): 42
Total # of Step1 poisson genes (theta=Inf; variance < mean): 44
Total # of poisson genes (theta=Inf; variance < mean): 42
Calling offset model for all 42 poisson genes
Found 20 outliers - those will be ignored in fitting/regularization step

Ignoring theta inf genes
Replacing fit params for 42 poisson genes by theta=Inf
Error in umi@x : 
  no applicable method for `@` applied to an object of class "matrix"
ceesu commented 12 months ago

I don't really know why, but I found that I could avoid this error if I deleted the data slot in RNA assay. I had converted the object from h5ad to h5seurat using seuratdisk which filled the data and counts slot of RNA assay with the same matrix, .X.