Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with vars.to.regress: "contrasts can be applied only to factors with 2 or more levels" #8780

Open
yesitsjess opened this issue Apr 16, 2024 · 1 comment

Comments

@yesitsjess
Copy link

When running:
soup_obj <- SCTransform(soup_obj, vars.to.regress="Sex")

I get the error:

Regressing out Sex
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
  contrasts can be applied only to factors with 2 or more levels

But my variable "Sex" is a factor with two levels:

> table(soup_obj$Sex)
  Male Female 
205006  49637 
> levels(soup_obj$Sex)
[1] "Male"   "Female"

Seurat_5.0.3

@saketkc saketkc transferred this issue from satijalab/sctransform Apr 16, 2024
@ashipde
Copy link

ashipde commented Apr 28, 2024

I am facing the exact issue (Seurat 5.0.3)

> ce
An object of class Seurat 
13336 features across 50032 samples within 1 assay 
Active assay: RNA (13336 features, 0 variable features)
 12 layers present: counts.nf1, counts.om1, counts.of2, ...

> ce <- SCTransform(cv, vars.to.regress='Batch', verbose=FALSE)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
  contrasts can be applied only to factors with 2 or more levels

> str(ce$Batch)
 Factor w/ 2 levels "A","B": 1 1 1 1 1 1 1 1 1 1 ...
 - attr(*, "names")= chr [1:50032] "om1_TACTGCCCAACCACGC-1 ...

> table(ce$Batch)

    A     B 
40787  9245 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants