subsetting seurat object to have equal cell numbers in different samples
0
0
Entering edit mode
13 months ago
Nal23 • 0

Hi, I am trying to subset a merged Seurat object (containing 5 different samples). Some samples have over 20,000 cells while some only have around 10,000 so I want to subset the merged object so that all samples have a similar cell distribution. I'm struggling to do this with the subset function and hope someone will be able to help me with this.

I can subset the whole object using this script but is there a way I can modify it to specify to subset each sample so that there are only 10,000 cells in each sample within the merged object?

subcells <- sample(Cells(filter_AS), size=10000, replace=F)
filter2_AS <- subset(x = filter_AS, cells = subcells)

Thanks so much!

single-cell scRNASeq Seurat • 1.7k views
ADD COMMENT
1
Entering edit mode

Try

Idents(filter_AS) <- "orig.ident"
filter2_AS <- subset(filter_AS, downsample=1e4)

Replace 'orig.ident' with whatever metadata column is holding your sample identity.

ADD REPLY

Login before adding your answer.

Traffic: 1596 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6