美文网首页BioStatR_Advance生信修炼
基本突变情况热图绘制

基本突变情况热图绘制

作者: 因地制宜的生信达人 | 来源:发表于2018-01-23 12:08 被阅读862次

对于测序相关文章,有一张漂亮的基因突变全景图可以为文章增色不少。下面我们就来一步步看怎么绘制漂亮的全景图。

基本热图绘制

安装R包complexheatmap

导入数据

mat = read.table(paste0(system.file("extdata", package = "ComplexHeatmap"), 
                        "/tcga_lung_adenocarcinoma_provisional_ras_raf_mek_jnk_signalling.txt"), 
                 header = TRUE,stringsAsFactors=FALSE, sep = "\t")
mat[is.na(mat)] = ""
mat <- mat[1:50,1:28]
rownames(mat) = mat[, 1]
mat = mat[, -1]
mat=  mat[, -ncol(mat)]
mat = t(as.matrix(mat))
###设置参数
col = c("MUT" = "#008000", "INDEL" = "red", "nonstop" = "blue","nonsense"= "yellow")
alter_fun = list(
  background = function(x, y, w, h) {
    grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "#CCCCCC", col = NA))
  },
  INDEL = function(x, y, w, h) {
    grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = col["INDEL"], col = NA))
  },
  nonstop = function(x, y, w, h) {
    grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = col["nonstop"], col = NA))
  },
  MUT = function(x, y, w, h) {
    grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = col["MUT"], col = NA))
  },
  nonsense = function(x, y, w, h) {
    grid.rect(x, y, w-unit(0.5, "mm"),  h-unit(0.5, "mm"), gp = gpar(fill = col["nonsense"], col = NA))
  }
)

画图

oncoPrint(mat, get_type = function(x) strsplit(x, ";")[[1]],
          alter_fun = alter_fun, col = col, 
          remove_empty_columns = TRUE,show_pct = TRUE, pct_gp = gpar(fontsize = 8),row_names_gp = gpar(fontsize = 8),
          column_title = "OncoPrint for TCGA Lung Adenocarcinoma
          genes in Ras Raf MEK JNK signalling",
          heatmap_legend_param = list(title = "Alternations", at = c("INDEL", "nonstop", "MUT","nonsense"), labels = c("INDEL", "nonstop", "Mutation","nonsense")))
image
mat = read.table(paste0(system.file("extdata", package = "ComplexHeatmap"),
"/tcga_lung_adenocarcinoma_provisional_ras_raf_mek_jnk_signalling.txt"),
header = TRUE,stringsAsFactors=FALSE, sep = "\t")
mat[is.na(mat)] = ""
mat <- mat[1:50,1:28]
rownames(mat) = mat[, 1]
mat = mat[, -1]
mat=  mat[, -ncol(mat)]
mat = t(as.matrix(mat))
col = c("MUT" = "#008000", "INDEL" = "red", "nonstop" = "blue","nonsense"= "yellow")
alter_fun = list(
background =  function(x, y, w, h) grid.rect(x, y, w, h, gp = gpar(fill = "white")),
INDEL = function(x, y, w, h) {
w = convertWidth(w, "cm")
h = convertHeight(h, "cm")
r = min(unit.c(w, h))*0.5
grid.circle(x, y, r*0.5, gp = gpar(fill = col["INDEL"], col = NA))
},
nonstop = function(x, y, w, h) {
w = convertWidth(w, "cm")
h = convertHeight(h, "cm")
r = min(unit.c(w, h))*0.5
grid.circle(x, y, r*0.5, gp = gpar(fill = col["nonstop"], col = NA))
},
MUT = function(x, y, w, h) {
w = convertWidth(w, "cm")
h = convertHeight(h, "cm")
r = min(unit.c(w, h))*0.5
grid.circle(x, y, r*0.5, gp = gpar(fill = col["MUT"], col = NA))
},
nonsense = function(x, y, w, h) {
w = convertWidth(w, "cm")
h = convertHeight(h, "cm")
r = min(unit.c(w, h))*0.5
grid.circle(x, y, r*0.5, gp = gpar(fill = col["nonsense"], col = NA))
}
)
oncoPrint(mat, get_type = function(x) strsplit(x, ";")[[1]],
alter_fun = alter_fun, col = col,
remove_empty_columns = TRUE,show_pct = F, pct_gp = gpar(fontsize = 8),row_names_gp = gpar(fontsize = 8),show_row_barplot = TRUE,
column_title = "OncoPrint for TCGA Lung Adenocarcinoma
genes in Ras Raf MEK JNK signalling",
heatmap_legend_param = list(title = "Alternations", at = c("INDEL", "nonstop", "MUT","nonsense"), labels = c("INDEL", "nonstop", "Mutation","nonsense")))

相关文章

  • 基本突变情况热图绘制

    对于测序相关文章,有一张漂亮的基因突变全景图可以为文章增色不少。下面我们就来一步步看怎么绘制漂亮的全景图。 基本热...

  • pheatmap包学习

    pheatmap pheatmap热图绘制 加载所需要的包 读入数据 查看数据 最初原始的热图绘制 热图颜色的调整...

  • 最简单最实用的R语言热图绘制教程(没有R基础-上手只需10min

    最简单最实用的R语言热图绘制教程(没有R基础-掌握只需10min) 前面用Excel绘制热图,在熟练的情况下,操作...

  • 热图绘制

    Rstudio基础----热图绘制 热图绘制 公众号链接: http://mp.weixin.qq.com/s/m...

  • 热图

    静态与交互式热图: heatmap():用于绘制简单热图的函数heatmap.2():绘制增强热图的函数d3hea...

  • 热图绘制

  • 热图绘制

    从全部差异基因筛选出一定阈值(FC,P值)筛选以后得到差异基因,再从所有差异基因的表达矩阵中筛选出最终差异基因的表...

  • 热图绘制

    先上图 npgene.csv 理化end.CSV同上

  • 获取pheatmap热图聚类后和标准化后的结果

    pheatmap是简单常用的热图绘制包,可以快速、简单、可定制的绘制漂亮热图。具体见R语言学习-热图简化和免费高颜...

  • 1 初识Complexheatmap

    ComplexHeatmap绘制的热图种类分为: ① Heatmap 类:单个热图,包括热图主体、行/列名称、标题...

网友评论

    本文标题:基本突变情况热图绘制

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