我正在尝试使用带有 R“circlize”包的树状图绘制单个圆形聚集热图。可从此pastebin 链接获得两列表达式数据
我正在使用以下代码进行绘图,主要来自circlize 手册:
dataURL <- "https://pastebin.com/raw/whLr21ZA"
expData.df<- read.table(dataURL,header=TRUE,sep="\t",stringsAsFactors=FALSE)
expData.mat <- as.matrix(expData.df[-c(1)])
rownames(expData.mat) <- expData.df$Mol
useT.mat <- t(expData.mat)
mat_list = list(a = useT.mat)
dend_list = list(a = as.dendrogram(hclust(dist(t(mat_list[["a"]])))) )
col_fun = colorRamp2(breaks= c(-13.288,-5.265,-6.674,-2.544,4.694,5.000), colors = c("blue4","lightblue","yellow","orange","orangered", "red"),transparency = .4)
factors = rep(letters[1], times = c( dim(useT.mat)[2] ))
circos.par(cell.padding = c(0, 0, 0, 0), gap.degree = 15)
circos.initialize(factors, xlim =cbind(c(0), table(factors)))
circos.track(ylim = c(0, 1), bg.border = NA, panel.fun = function(x, y) {
sector.index = CELL_META$sector.index
m = mat_list[[sector.index]]
dend = dend_list[[sector.index]]
m2 = m[, order.dendrogram(dend)]
col_mat = col_fun(m2)
nr = nrow(m2)
nc = ncol(m2)
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, ])
}
})
#Dendrogram
max_height = max(sapply(dend_list, function(x) attr(x, "height")))
circos.track(ylim = c(0, max_height), bg.border = NA, track.height = 0.3,
panel.fun = function(x, y) {
sector.index = get.cell.meta.data("sector.index")
dend = dend_list[[sector.index]]
circos.dendrogram(dend, max_height = max_height)
})
circos.clear()
部分图形超出了顶部和底部的绘图区域。
我不知道如何在图中放置行和列标签
任何人都可以帮助解决这两个问题吗?
谢谢