That worked perfectly well!. Thanks a lot
Hi. I am working with scRNAseq data from 5 different samples (3 patients and 2 controls). I am able to integrate them, create a Seurat file and obtain nice clusters. However I am struggling to group the 3 patients and the 2 controls together to compare gene expression between patients and controls. For example if use VlnPlot to show expression of one and I write the command group.by="orig.ident" it shown the expression of the gene by each 5 condition (patient 1, patient 2, patient 3, control1 and control 2). I am unable to find out how to show gene expression by patient vs control. Any idea?
1 answer
You need to add a column in the metadata (seuratObject@meta.data) containing your grouping, so that each UMI are classified.
For example:
control_samples <- c("C1","C2")
seuratObject@meta.data$condition <- sapply(seuratObject@meta.data$orig.ident, function(ita) ifelse(ita %in% control_samples,"Control","Patient")
Then you can group.by="condition"
Just a general comment but seuratObject$condition works as well since they defined Seurat specific methods for $ and $<- to set and get metadata. Generally you don't want to access slots in S4 objects directly since by R convention the slots can change without documentation, but the generics and methods setting and getting slots should in theory always point to the correct location.
I do agree with you, but since the painful migration from seurat 2 to seurat 3 I prefer to point directly to the slots to retrieve data. Between versions, the seurat structure has not changed that much, while the specific methods have.
Thanks a lot for your answer. That worked perfectly well!!
Thanks again
Log in to answer this question.