Seurat中小提琴图,热图顺序的调整

2020-04-01 15:51:01 浏览数 (2)

改变小提琴横坐标的顺序

代码语言:javascript复制
seurat.object_copy <- seurat.object
my_levels <- c(set_your_order_of_clusters)
Idents(seurat.object_copy) <- factor(Idents(seurat.object_copy), levels= my_levels)
VlnPlot(seurat.object_copy, features = c("some_gene"))

因为顺序变了,要是想保持原来每个样本对应的颜色的话,也要改变小提琴的颜色.如: 原始的样子

代码语言:javascript复制
VlnPlot(=combined,features = T,log = F,slot = "data",pt.size = 0)

image.png

改变顺序

代码语言:javascript复制
combined_copy <- combined
My_levels <- c('pluripotency','mesendoderm','mesoderm','endoderm')
Idents(combined_copy) <- factor(Idents(combined_copy), levels= My_levels)

image.png

重新匹配颜色

代码语言:javascript复制
VlnPlot(=combined_copy,features = T,log = F,slot = "data",pt.size = 0) scale_fill_manual(values = c("#C77CFF","#7CAE00","#00BFC4","#F8766D")))

如果不知道原来的颜色:

代码语言:javascript复制
library(scales)
show_col(hue_pal()(4)) 

Heatmap调整热图颜色为scale_fill_gradientn()

代码语言:javascript复制
DoHeatmap(object = pbmc_small) 

image.png

代码语言:javascript复制
library(ggplot2)
DoHeatmap(object = pbmc_small)   scale_fill_gradientn(colors = c("blue", "white", "red"))

image.png

Heatmap调整上面bar的颜色

代码语言:javascript复制
DoHeatmap(subset(combined_copy,downsample = 100), features = combined.markersTop50$gene,label = F,group.bar.height = 0.1,group.colors = c("#C77CFF","#7CAE00","#00BFC4","#F8766D"))

调整group顺序

代码语言:javascript复制
combined_copy$integrated_merge_cluster <- factor(x =NC_TBXTKO_TCF7KO.combined_copy$integrated_merge_cluster, levels = c('mesoderm','endoderm','pluripotency','mesendoderm'))
DoHeatmap(subset(NC_TBXTKO_TCF7KO.combined_copy,downsample = 100), features = NC_TBXTKO_TCF7KO.combined.markersTop50$gene,label = F,group.bar.height = 0.1,group.by ="integrated_merge_cluster")

image.png

如果要修改gene的顺序的话,修改level后重新运行FindAllMarkers.

参考:

https://github.com/satijalab/seurat/issues/454

欢迎关注~

0 人点赞