自从开始分析各种组学数据。热图绝对是一个天天见的好朋友。然而,天天见了总是会生腻的,再加上有些时候为了保留尽量多的分析结果可以同时呈现,热图兄弟实在是太长呢。
想来想去,不如把热图变成一个圈圈来看看吧。如下:
原来很多文章里面用来画染色体分布的图,也可以用来呈现热图呢。
附上我的小代码:
library(OmicCircos)
##My data is input.corrs, colunm 'a','b' are two correlated items
input.corrs = input.corrs[order(input.corrs$a),]
factors = factor(input.corrs$a)
imp.corrs.list = list()
for(i in 1:length(unique(factors))){
item = unique(factors)[i]
a.list = as.matrix(input.corrs[input.corrs$a == item,tumors])
imp.corrs.list[[i]] = a.list
}
names(imp.corrs.list)=unique(factors)
####Circlized visulation of a series of correlations###
library(circlize)
circos.par(cell.padding = c(0, 0, 0, 0), gap.degree = 5)
circos.initialize(factors, xlim = cbind(c(0, 0), table(factors)))
col_fun = colorRamp2(c(-0.6,0,0.6), c("blue","white", "red"))
##four circles in the outside
circos.track(ylim = c(0, 3), bg.border = NA, panel.fun = function(x, y) {
sector.index = get.cell.meta.data("sector.index")
print(sector.index)
m = t(imp.corrs.list[[sector.index]])
col_mat = col_fun(m)
nr = nrow(m)
nc = ncol(m)
for(i in 1:nr) {
circos.rect(1:nc - 1, rep(nr - i, nc),
1:nc, rep(nr - i + 1, nc),
border = col_mat[i, ], col = col_mat[i, ])
}
})
cols.t<-rainbow(length(unique(factors)))
names(cols.t)<-unique(factors)
##the inner most circle
circos.trackPlotRegion(ylim = c(0, 1), panel.fun = function(x, y) {
fc = get.cell.meta.data("sector.index")
xlim = get.cell.meta.data("xlim")
ylim = get.cell.meta.data("ylim")
circos.rect(xlim[1], 0, xlim[2], 0.5,
col = cols.t[fc])
circos.text(mean(xlim), -0.5, fc, cex = 0.5, facing = "clockwise", niceFacing = TRUE)
}, bg.border = NA)
circos.clear()
input.corrs 内容如下:
a b tumor1 tumor2 tumor3 tumor4
gene1 gene2 0.35 0.03 0.44 0.98
gene1 gene21 0.12 -0.19 0.33 0.15
上面热图最里面是根据‘a’列内容上色,其他四个圈表示了四种tumor中的关联程度。
具体使用方法请移步 OmicCircos
热图可以这么美!