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

vst and batch_var correction does not work #97

Closed FelixErnst closed 3 years ago

FelixErnst commented 3 years ago

Hi,

the following does not work

library(sctransform)
cell_attr <- data.frame(batch = sample.int(2,ncol(pbmc),replace=TRUE))
vst(pbmc,cell_attr = cell_attr, batch_var = "batch")
>Calculating cell attributes from input UMI matrix: log_umi
>Error in is.nan(rel_attr) : 
>  default method not implemented for type 'list'

In sctransform:::make_cell_attr the subset at the end was probably written with only variable in mind. Since drop=TRUE this returns a vector, so that the checks make sense. If two or more variables are present, it does not get dropped to vector, therefore the checks break.

Can you fix this? Thanks

Felix

ChristophH commented 3 years ago

Thank you for posting this issue and providing a reproducible example 👍

However, this problem has already been described in #88, and as a result, is mentioned in the known issues section of the main page. Fixed in the develop branch.