• 热图 | heatmap | 高通量数据可视化经典图形


    高通量数据搞来搞去,都离不开那几图来呈现结果,因为那些图实在是太经典了,高度概括了测序数据的分析结果。

    热图heatmap:

    1. 基因表达矩阵的直观可视化
    2. 数据之间的两两比较,相关性分析,相似性分析

    可视化的对象也非常简单,就是一个表,也叫dataframe或matrix。

    我最喜欢用pheatmap这个R包,非常好用,也基本涵盖了你想要的所有功能。

    我的数据,就是两组样本的相关性矩阵,来看相似性。

    corM <- cor(as.matrix(human.BP.expr), as.matrix(mouse.BP.expr), method = "spearman")
    

      

    library(pheatmap)
    library(ggplot2)
    

      

    改个label的名字

    rownames(corM) <- plyr::mapvalues(rownames(corM), 
                    from = c("IMR_ENCC","UE_ENCC","HSCR_5c3","HSCR_20c7","HSCR_10c2","HSCR_1c11","HSCR_17c8","HSCR_23c9","HSCR_6c5"),
                    to = c("IMR90","UE02302","HSCR#5","HSCR#20","HSCR#10","HSCR#1","HSCR#17","HSCR#23","HSCR#6"))
    

      

    colnames(corM) <- plyr::mapvalues(colnames(corM), 
                    from = c("E13.5_CNCC"),
                    to = c("E13.5 "))
    

      

    设置顺序

    corM <- corM[c("IMR90","UE02302","HSCR#5","HSCR#20","HSCR#10","HSCR#1","HSCR#17","HSCR#23","HSCR#6"),
                 c("E9.5","E10.5","E11.5","E12.5","E13.5","E16.5","P19","P21","E13.5 ")]
    

      

    设置侧边栏的bar的分组和颜色

    annotation_row = data.frame(Severity=c("Control","Control","S-HSCR","S-HSCR","S-HSCR","S-HSCR","L-HSCR","L-HSCR","TCA"),
                                row.names=c("IMR90","UE02302","HSCR#5","HSCR#20","HSCR#10","HSCR#1","HSCR#17","HSCR#23","HSCR#6"))
    
    annotation_col = data.frame(row.names=c("E9.5","E10.5","E11.5","E12.5","E13.5","E16.5","P19","P21","E13.5 "),
                                Lineage=c("ENCC","ENCC","ENCC","ENCC","ENCC","ENCC","ENCC","ENCC","CNCC"))
    
    annotation_colors = list(Severity=c(Control="#4DAF4A", `S-HSCR`="#E41A1C", `L-HSCR`="#984EA3", TCA="gray70"),
                             Lineage=c(ENCC="green", CNCC="#eb6566"))
    

      

    核心画图函数

    options(repr.plot.width=7.0, repr.plot.height=6)
    p <- pheatmap(corM, cluster_rows = F, cluster_cols = F, display_numbers = T, border_color=NA, 
                  number_color="white", fontsize_number = 11, angle_col=315,
                  annotation_row=annotation_row, annotation_colors=annotation_colors,
                  annotation_col = annotation_col, gaps_col =c(8),
                  color = colorRampPalette(rev(hcl.colors(100)))(100))
    # brewer.pal(n = 7, name = "RdYlBu")

      

    其中有几个参数要重点说明:

    display_numbers:是否显示数值

    border_color:是否有边框的线

    angle_col:label的旋转,非常方便

    gaps_col:自行分组,非常实用的功能,就是拆分,这里不用聚类,随意分

    hcl.colors:非常好看的热图的配色

    保存PDF

    pdf("Figures/correlation.enteric.evidence.pdf",width = 7, height = 6)
    p
    dev.off()
    

      

    参考:

    pheatmap绘制“热图”,你需要的都在这

  • 相关阅读:
    换行的展示
    jsp页面的导出功能
    怎么设置回车键为提交功能?
    HBuilder使用心得
    js和jQuery
    前端常用技术总结--java程序员
    对压缩文件加密
    删除表中一个字段的SQL语句
    用NPOI操作EXCEL-锁定列CreateFreezePane()
    MVC 点击下载文档
  • 原文地址:https://www.cnblogs.com/leezx/p/15818298.html
Copyright © 2020-2023  润新知