具有固定外部树形图的热图

时间:2016-07-15 06:59:36

标签: r external heatmap dendrogram

我正在制作热图并添加外部树形图。我在how to create a heatmap with a fixed external hierarchical cluster的帖子中做了,但行保持重新排序。代码如下:

    #TREE input
rep_tr <- read.tree(file= "tree.tre")


#first check 
is.ultrametric(rep_tr)
is.binary.tree(rep_tr)
is.rooted(rep_tr)
#fix and check if didnt pass
tree1 <- chronos(rep_tr)
is.ultrametric(tree1)


myTree.bifurcating<-multi2di(tree1)
is.binary.tree(myTree.bifurcating)



hc <- as.hclust.phylo(myTree.bifurcating)



tre <- as.phylo(hc)

dend <- as.dendrogram(hc)

plot(dend, horiz=TRUE)


#labels in dend but bottom to top. ANd order matrix 
h <- labels(dend)
hi <- matdata[h,]
b <- apply(hi, 2, rev)

pdf("class_tree.pdf")

heatmap.2(b, Rowv=dend, Colv=NA, dendrogram='row', col = colorpanel(9,"red","yellow","green"), density.info = "none", key=TRUE, keysize=1, margins = c(5,10), trace = "none", xlab = "Samples",  main = "Class", cexRow=0.7, cexCol=.5,  na.color="white")

dev.off()

树形图被添加。我将Rowv放入树形图,但行重新排序。

0 个答案:

没有答案