3
$\begingroup$

I have a Seurat object existing of an aggregate of two samples namely; RD1 and RD2. I am trying to make a subset of each sample. But it's not really working. I manage to make a subset of the cells but I don't manage to make a subset of the whole object. Isn't there a way to do this, based on the subset from cell names a subset to make from the whole object.

seuratObj$orignal_1 <- seuratObj@meta.data$orig.ident
seuratObj$orignal_2 <- seuratObj@meta.data$orig.ident
seuratObj$orignal_1 <- gsub("RD1", "TRUE",seuratObj$orignal_1 )
seuratObj$orignal_1  <- gsub("RD2", "False",seuratObj$orignal_1  )
seuratObj$orignal_2  <- gsub("RD1k", "TRUE",seuratObj$orignal_2  )
seuratObj$orignal_2  <- gsub("RD2", "False",seuratObj$orignal_2  )

subset_DR1 <- data.frame(orignal_1 = seuratObj$orignal_1)
subset_DR1 <- subset(subset_DR1, orignal_1 == TRUE,select = c("orignal_1"))

subset_DR2 <- data.frame(orignal_2 = seuratObj$orignal_2)
subset_DR2 <- subset(subset_DR2 , orignal_2 == TRUE,select = c("orignal_2"))

SubsetData(seuratObj, cells = rownames(subset_DR1), subset.name = seuratObj$orignal_1)

I just started to work with seurat packages. I think I am missing something.

$\endgroup$
  • $\begingroup$ Welcome to the site ageans. Did you try to create two seurat objects one for each sample? (Instead of dividing this single seurat object?) $\endgroup$ – llrs Jul 19 at 7:27
  • $\begingroup$ Yes, I have 1 suerat object and now I am trying to divide them into two Seurat object, 1 for each sample. $\endgroup$ – ageans Jul 19 at 7:36
  • $\begingroup$ Ok, but can't you create from the start two seurat objects? $\endgroup$ – llrs Jul 19 at 7:43
  • $\begingroup$ Sadly enough now because it's an old object. And I only got the object. And for the rest of the analysis, it should be 1 object. But for 1 part I need to separate it. $\endgroup$ – ageans Jul 19 at 7:57
  • $\begingroup$ Can you post some information on the meta data? Do you have a column in the metadata that annotates the subset?Also assign the subset to new object, subset_obj <- SubsetData() if you use seurat2, subset_obj <- subset(x = seuratObj, subset = orig.ident == "Replicate1") if you use seurat3. $\endgroup$ – Mack123456 Jul 26 at 1:41
2
$\begingroup$

I think your issue is simply not assigning the newly-subset object in to a new object.

Assuming rownames(subset_DR1) is indeed a list of cell names

seuratObj_subset_dr1 <- SubsetData(seuratObj, cells=rownames(subset_DR1))

will work.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.