Seurat changing order cluster shown in the violin plot
1
0
Entering edit mode
6 months ago
camillab. ▴ 160

Hi,

I have scRNAseq with total of 33 clusters and I want to select only few of them (eg. cluster 0,3,6,7) and plot specific genes in a violin plot. However ideally I would like to have the clusters shown in specific order in the violin plot (eg. cluster 7,3,6,0) and I tried to follow this post but I am still not getting the results ordered in the way I want.

Specifically my code (the order that I want is 1. Myofibrocytes 2. Erythtrocyes 3. Endothelial cells 4. Fibrocytes :

pbmc2 <- subset( immune.combined , idents = c("Myofibrocytes", "Erythtrocyes", "Endothelial cells", "Fibrocytes"))
pbmc2$celltype.stim <- paste(Idents(pbmc2), pbmc2$sample, sep = "_") #assign the same on a new colunm
pbmc2$celltype <- Idents(pbmc2) # assign the identify to the cell type colunm
Idents(pbmc2) <- "celltype.stim"
levels(pbmc2)

VlnPlot(pbmc2, features = c("Hes1", "Hey1", "Hey2", "Heyl", "Notch1", "Notch2", "Notch3", "Atf4"), 
        pt.size = 0, assay = "RNA",  stack = T, flip = T, fill.by = "ident",split.by = "sample.New", group.by ="celltype") 

and I got this plot : enter image description here

and I try to follow the post:

object_copy <- pbmc2
my_levels <- c("Myofibrocytes", "Erythtrocyes", "Endothelial cells", "Fibrocytes")
Idents(object_copy) <- factor(Idents(object_copy), levels= my_levels)
VlnPlot(object_copy, features = c("Hes1", "Hey1", "Hey2", "Heyl", "Notch1", "Notch2", "Notch3", "Atf4"), 
        pt.size = 0, assay = "RNA",  stack = T, flip = T, fill.by = "ident",split.by = "sample.New", group.by ="celltype") 

I got the same plot . What I am doing wrong? Thank you!

Camilla

R violin Seurat • 1.4k views
ADD COMMENT
1
Entering edit mode
6 months ago
bk11 ★ 2.4k

You can arrange the order like this before plotting.

pbmc2$celltype <- factor(pbmc2$celltype, levels = c("Myofibrocytes", "Erythtrocyes", "Endothelial cells", "Fibrocytes"))

#then run your VlnPlot function
VlnPlot(pbmc2, features = c("Hes1", "Hey1", "Hey2", "Heyl", "Notch1", "Notch2", "Notch3", "Atf4"), 
        pt.size = 0, assay = "RNA",  stack = T, flip = T, fill.by = "ident",split.by = "sample.New", group.by ="celltype") 
ADD COMMENT
0
Entering edit mode

thank you!!

ADD REPLY

Login before adding your answer.

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