用途:一般我們畫熱圖是以連續變量作為填充因子,complexHeatmap的oncopoint函數可以以類別變量作為填充因子作熱圖。
用法:oncoPrint(mat, get_type = function(x) x,alter_fun = alter_fun_list, alter_fun_list = NULL, col,row_order = oncoprint_row_order(),column_order = oncoprint_column_order(),show_column_names = FALSE,show_pct = TRUE, pct_gp = gpar(), pct_digits = 0,....)
mat:類別矩陣。
get_type:得到數據中的類別。
alter_fun:函數list,具體說明每個類別要怎么畫。
col:圖例的顏色
第一步:寫腳本把數據轉換成符合要求的mat類型。
第二步:用oncoPrint函數畫圖。
alter_fun=list(
background=function(x,y,w,h){grid.rect(x,y,w,h,gp=gpar(fill="white",col=NA))}##針對NA設置 indel=function(x,y,w,h){grid.rect(x,y,w,h,gp=gpar(fill="red",col=NA))} snv=function(x,y,w,h){grid.reat(x,y,w,h,gp=gpar(fill="blue",col=NA))}) col=c(indel="red",snv="blue")#圖例的顏色,必須寫明每個類別的顏色。 oncoPrint(mat,get_type=function(x) {strsplit(x,";")[[1]]},alter_fun=alter_fun,col=col)
參考文章:
http://www.bioconductor.org/packages/3.3/bioc/vignettes/ComplexHeatmap/inst/doc/s8.oncoprint.html