玩转单细胞(4):单细胞相关性

2023-01-02  本文已影响0人  KS科研分享与服务

参考文献:

(Reference:Immunophenotyping of COVID-19 and influenza highlights the role of type I interferons in development of severe COVID-19)

看到一篇文献,做的单细胞细胞类型间的相关性,之前有小伙伴也问过这个小问题,这里简单演示一下:至于选择多少基因,自己决定。或者也可以自己定义基因集。


library(Seurat)
library(pheatmap)
Idents(mouse_data)<- mouse_data$celltype
av.exp<- AverageExpression(mouse_data)$RNA
# av.exp<- av.exp[which(row.names(av.exp)%in% features),]

features=names(tail(sort(apply(av.exp, 1, sd)),2000))
av.exp<- av.exp[which(row.names(av.exp)%in% features),]
av.exp <- cor(av.exp, method= "spearman")
pheatmap::pheatmap(av.exp)

做一个分析和一个图,就是为了某种意义,没有意义作甚呢?根据那个文献,他做的目的是为了疾病和正常组细胞转录层面的区别。这里我们将性别和细胞类型结合,做一下相关看看(我们的数据是没有意义的,所以结果也是如此)!


library(tidyr)
colnames(mouse_data@meta.data)
mouse_data@meta.data <- unite(mouse_data@meta.data, 
                              "sex_celltype", 
                              sex, celltype, 
                              remove = FALSE)


Idents(mouse_data)<- mouse_data$sex_celltype
exp<- AverageExpression(mouse_data)$RNA
features=names(tail(sort(apply(exp, 1, sd)),2000))
exp<- exp[which(row.names(exp)%in% features),]
exp <- cor(exp, method= "spearman")

#行列注释
annotation_col = data.frame(
  celltype = c("PMN(3)","PMN(2)","PMN(1)", "PMN(0)" ,"PMN(5)" ,"PMN(6)", "PMN(4)", "PMN(7)",
               "PMN(2)", "PMN(1)", "PMN(6)", "PMN(3)" ,"PMN(0)" ,"PMN(5)" ,"PMN(4)" ,"PMN(7)"),
  Sex = c(rep("F",8),rep("M",8))
)

row.names(annotation_col) <- colnames(exp)


annotation_row = data.frame(
  celltype = c("PMN(3)","PMN(2)","PMN(1)", "PMN(0)" ,"PMN(5)" ,"PMN(6)", "PMN(4)", "PMN(7)",
               "PMN(2)", "PMN(1)", "PMN(6)", "PMN(3)" ,"PMN(0)" ,"PMN(5)" ,"PMN(4)" ,"PMN(7)"),
  Sex = c(rep("F",8),rep("M",8))
)
row.names(annotation_row) <- rownames(exp)


#做热图
pheatmap::pheatmap(exp, annotation_col = annotation_col,
                   annotation_row = annotation_row, 
                   color = rev(RColorBrewer::brewer.pal(n = 10, name = "RdBu")))

以上就是这期全部内容了,希望对你有帮助,觉得有用的,分享一下,点个赞、点一下再看呗,谢谢支持!更多精彩内容请至我的公众号---KS科研分享与服务

上一篇下一篇

猜你喜欢

热点阅读