satijalab / sctransform

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

How to specify genes for normalization? #77

Open huoqiang138 opened 3 years ago

huoqiang138 commented 3 years ago

Hi Christoph, Thanks for all your work. When we use Scaledata we can specify the gene, for example"pbmc <- ScaleData(pbmc,features = all.genes,vars.to.regress = "percent.mt")", "features"can can specify the gene.So how to specify the desired gene in SCTransform? Many thanks in advance

ChristophH commented 3 years ago

If I understand correctly, you don't want the Pearson residuals (normalized data) for all genes, but only for a subset. You can do so in a two-step process:

vst_out <- vst(umi = pbmc, residual_type = 'none', return_cell_attr = TRUE)
norm_counts <- get_residuals(vst_out = vst_out, umi = pbmc[c('GZMK', 'PPBP', 'LYZ'), ])

This way vst will not return a residual matrix, but only estimate the model parameters. When you then call get_residuals you can use a subset of the original counts matrix to get only the residuals that you are interested in.

huoqiang138 commented 3 years ago

Ruinning

vst_out <- vst(umi = pbmc, residual_type = 'none', return_cell_attr = TRUE) Calculating cell attributes from input UMI matrix: log_umi gives: Error in h(simpleError(msg, call))

ChristophH commented 3 years ago

What is pbmc in your case? In my example it is a count matrix that comes with the package, i.e. sctransform::pbmc. What version of sctransform are you using? Please install from the develop branch with this command: remotes::install_github("ChristophH/sctransform@develop"). Finally, if you still see the error, please prove the output of the traceback() command run right after the error shows up. Also provide the output of sessionInfo().