单细胞亚群差异基因火山图

作者: Hayley笔记 | 来源:发表于2022-03-08 13:03 被阅读0次

    单细胞绘图系列:


    做单细胞分析的时候,我们常规画的火山图和RNAseq的分析其实是一样的。见火山图EnhancedVolcano。但是因为单细胞自身特性导致,它两个分组的细胞数量太多,很大概率会导致p值过于显著,无限接近于0的情况,导致火山图的结果很诡异。

    最近在文献里看到了这样的火山图

    单细胞测序揭示病毒性心肌炎细胞图谱和转录网络

    CD177调节肿瘤浸润Treg细胞的功能和稳态

    这种展现方式可以忽略这个统计学指标p值,因为反正都是统计学显著的,大于0.01即可,p值再小也不是我们关心的重点。

    绘制方法

    用pbmc3k数据集做演示

    library(Seurat)
    library(patchwork)
    library(clusterProfiler)
    library(org.Mm.eg.db) ##加载小鼠
    library(org.Hs.eg.db) ##加载人类
    library(tidyverse)
    pbmc <-readRDS("pbmc.rds")
    table(pbmc$cell_type)
    object.markers <- FindMarkers(pbmc, ident.1 = 'Memory CD4 T',ident.2 = 'Naive CD4 T', 
                                  group.by = 'cell_type',logfc.threshold = 0,min.pct = 0,pseudocount.use = 0.01)
    object.markers$names <- rownames(object.markers)
    #sig_dge.all <- subset(object.markers, p_val_adj<0.05&abs(avg_log2FC)>0.15) #所有差异基因
    #View(sig_dge.all)
    library(dplyr)
    object.markers <- object.markers %>%
      mutate(Difference = pct.1 - pct.2)
    library(ggplot)
    library(ggrepel)
    
    ggplot(object.markers, aes(x=Difference, y=avg_log2FC)) + 
      geom_point(size=0.5, color="#999999") + 
      geom_label_repel(data=subset(object.markers, avg_log2FC >= 1 & Difference >= 0.2 & pct.2 <= 0.05), aes(label=names), label.padding = 0.1, fill="tomato2", segment.size = 0.25, size=2.5)+
      theme_classic()
    ggsave("TopMarkerVol1.pdf", height=8, width=8)
    
    object.markers$group=0
    for (i in 1:nrow(object.markers)){
      if (object.markers$avg_log2FC[i] >= 1 & object.markers$Difference[i] >= 0.2 & object.markers$pct.2[i] <= 0.05){
        object.markers$group[i]='up'
      }
      else if(object.markers$avg_log2FC[i] <= -1 & object.markers$Difference[i] <= -0.2 & object.markers$pct.1[i] <= 0.05){
        object.markers$group[i]='down'
      }
      else {
        object.markers$group[i]='no'
      }
    }
    
    ggplot(object.markers, aes(x=Difference, y=avg_log2FC)) + 
      geom_point(size=0.5,aes(color=group)) + 
      scale_color_manual(values=c('blue','grey','red'))+
      geom_label_repel(data=subset(object.markers, group !='no'), aes(label=names), segment.size = 0.25, size=2.5)+
      geom_vline(xintercept = 0.0,linetype=2)+
      geom_hline(yintercept = 0,linetype=2)+
      theme_classic()
    ggsave("TopMarkerVol2.pdf", height=8, width=8)
    
    差不多吧,参数可以再调一调

    相关文章

      网友评论

        本文标题:单细胞亚群差异基因火山图

        本文链接:https://www.haomeiwen.com/subject/oararrtx.html