I'm trying to plot a single circular clustered heatmap with dendrogram with R "circlize" package. The two column expression data is available from this pastebin link
I'm using the following code for plotting, mostly lifted from the circlize manual:
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()
I'm having two issues while plotting the data:
Part of the figure is going outside of the plotting area on top and bottom.
I don't know how to put row and column labels in the figure
can anyone help in solving these two issues?
Thanks