绘制具有指定分支长度和彩色分支

时间:2017-05-03 16:55:42

标签: r plot tree draw

我想绘制一个具有指定分支长度的树...我尝试使用R,但我可以尝试使用您建议做的任何语言。

例如:

relationship <- matrix(c(c("a","b","c", 3), c("c", "d", "e", 2), c("d", "f", "g", 5), c("e","j","k", 1), c("g", "h", "i", 0.5), c("j", "l" , "m", 4), c("b","b","b", 10), c("f","f","f",3), c("h","h","h", 2.5), c("i","i","i", 2.5), c("l","l","l",3), c("m", "m", "m", 0.5), c("k","k","k",7)), ncol=4, byrow = T)
#the max length of the tree is supposed to be 13 here... I hope I didn't make a mistake.
mycol <- matrix(c(8, 11, "d", "red"), nrow=1) 

在这里,我选择将数据组织为13行和4列的矩阵。 或csv文件:

 root, child1, child2, distance 
 a,  b,  c,  3  
 c,  d,  e,  2  
 d,  f,  g,  5  
 e,  j,  k,  1  
 g,  h,  i,  0.5
 j,  l,  m,  4  
 b,  b,  b,  10 
 f,  f,  f,  3  
 h,  h,  h,  2.5
 i,  i,  i,  2.5
 l,  l,  l,  3  
 m,  m,  m,  0.5
 k,  k,  k,  7  

还有一个颜色工具:

begin, end, node, color
8, 11, d, red

子树的根,第一个子节点和第二个子节点之间的关系表示为三角形和相应的长度值。 该对应值是根节点与子节点之间的距离。 还描述了每棵树的叶子,其中3个值之间的关系是相同的id。

我想做

drawTree(relationship, rotate=T, label="leafandroot")

它返回:this tree

或者:

drawTree(relationship, rotate=T, label="leafandroot", color=mycol)

它返回:this colored tree

你知道这种情节是否存在包裹吗?我尝试了ggdendrotree套餐,似乎什么也没做我需要的......有什么建议吗?

0 个答案:

没有答案