美文网首页
pheatmap包绘制热图教程

pheatmap包绘制热图教程

作者: 小杜的生信筆記 | 来源:发表于2021-11-29 22:03 被阅读0次

    本篇博文属于恰饭哦,但是对你也有作用哦!!

    现在自己也分享一下自己这个历程,最后,最后,最后,还是一句话,“使用R画图,数据准备非常非常的重要”

    1 数据准备


    第一列,gene_id, 后面是重复,3个重复,我的共4个处理数据,12组

    2导入数据

    #文件所在位置
    setwd("I:FPKM")
    library(pheatmap)
    #BiocManager::install("heatmaps")  #如没有按照“pheatmap包请安装”
    dataset <-  read.table('FPKM_聚类图数据.txt',header = TRUE, row.names = 1)
    

    3 构建矩阵

    # 构建样本分类数据
    sample_calss=c(rep('CS_Leaf',3),
                   rep('CK_Lead',3),
                   rep('CS_Root',3),
                   rep('CK_Root',3))
    level = c(1:12)
    annotation_c <- data.frame(sample_calss, level)
    rownames(annotation_c) <- colnames(exp_ds)
    
    gene_class=c(rep('High',30),
                 rep('Low',30))
    sample_type=c(rep('CS',20),
                rep('CK',20),
                rep('Immunology',20))
    annotation_r <- data.frame(gene_class, gene_type)
    rownames(annotation_r) <- rownames(exp_ds)
    

    画图

    pheatmap(exp_ds, #表达数据
             cluster_rows = T,#行聚类
             cluster_cols = T,#列聚类
             annotation_col =annotation_c, #样本分类数据
             annotation_row = annotation_r,
             annotation_legend=TRUE, # 显示样本分类
             show_rownames = T,# 显示行名
             scale = "row", #对行标准化
             color =colorRampPalette(c("#8854d0", "#ffffff","#fa8231"))(100), # 热图基准颜色
    )
    

    结果图形


    原文链接

    相关文章

      网友评论

          本文标题:pheatmap包绘制热图教程

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