I am analyzing a merged dataset comprising of 4 samples (2 wildtype controls and 2 mutants), and I am having difficulty recalling only cells from certain samples for further downstream analysis (such as differential gene expression) post-clustering.
Seurat objects were created as so (samples would be: ctrl1, ctrl2, mut1, mut2):
control1_sample <- CreateSeuratObject(counts = control1.data, project = "control1", min.cells = 3, min.features = 200)
mutant2_sample <- CreateSeuratObject(counts = mutant2.data, project = "mutant2", min.cells = 3, min.features = 200)
, merged and clustered.
I'm trying to look at differential gene expression across samples within the same clusters, following vignettes such as: Integrating stimulated vs control datasets... and Differential expression testing, where cell identities ("stim" in the tutorial) are able to be distinguished using the group.by or split.by function.
I cannot seem to replicate this using the Seurat object project name as the label, resulting in an error:
DimPlot(object, reduction = "umap", split.by = "control1"
Error: Cannot find '____' in this Seurat Object
I thought "orig.ident" would allow me to bypass this, but I would like to compare certain samples, rather than just overlay all of them at once.
Am I understanding how this works correctly? Do I have to properly assign identities to certain datasets, and how would I recall them for downstream comparisons?
I would appreciate any insight and/or workarounds for this - Thank you
Hi @amdhome1,
Don't really get your question though... But you're using the wrong column to call the plot...
It should be:
DimPlot(object, reduction = "umap", split.by = "orig.ident")
if you want to split your plot by samples...
If you want your plot to split by condition (i.e. controls vs mutants), I would suggest having a column in the metadata which specifies their condition. Then, you can call the plot as:
DimPlot(object, reduction = "umap", split.by = "condition")
Setting the project parameter will control what gets placed in the orig.ident metadata column, so here orig.ident would separate cells based on the original dataset they came from. If you wanted to subset based on that information you could do something like this:
subset.object <- object[, object$orig.ident == "control1"]
to separate out cells from the "control1" dataset
If you want to do DE between treatment groups within a cluster you need to combine the treatment and cluster information as shown in the vignette. For example: object$treatment_cluster <- paste0(object$orig.ident, "_", object$seurat_cluster)
Most helpful comment
Hi @amdhome1,
Don't really get your question though... But you're using the wrong column to call the plot...
It should be:
DimPlot(object, reduction = "umap", split.by = "orig.ident")if you want to split your plot by samples...
If you want your plot to split by condition (i.e. controls vs mutants), I would suggest having a column in the metadata which specifies their condition. Then, you can call the plot as:
DimPlot(object, reduction = "umap", split.by = "condition")