Grouping datasets in Seurat
1
1
Entering edit mode
3.0 years ago

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?

groupin Seurat • 4.0k views
ADD COMMENT
6
Entering edit mode
3.0 years ago
fracarb8 ★ 1.7k

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"

ADD COMMENT
1
Entering edit mode

Thanks a lot for your answer. That worked perfectly well!!

Thanks again

ADD REPLY
0
Entering edit mode

That worked perfectly well!. Thanks a lot

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 2087 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