绘制表象时缺少树提示

时间:2014-01-18 21:13:54

标签: r plot phylogeny

当我使用phytools包生成表型时,树的提示和提示标签不会显示。有没有人对如何解决这个问题有任何想法,或者有另一种方法来绘制具有节点和提示的表位图,其中y轴绘制在所讨论的特征的值上?

这就是我所拥有的:

midpointData <-
structure(list(Species = structure(1:6, .Label = c("Icterus_croconotus", 
"Icterus_graceannae", "Icterus_icterus", "Icterus_jamacaii", 
"Icterus_mesomelas", "Icterus_pectoralis"), class = "factor"), 
    bio_1nam = c(243L, 193L, 225L, 209L, 189L, 180L), bio_12nam = c(5127.5, 
    751.5, 1373, 914.5, 4043.5, 2623.5), bio_16nam = c(1470.5, 
    442, 656.5, 542, 1392.5, 1074), bio_17nam = c(1094.5, 51.5, 
    135, 189.5, 768.5, 377.5), bio_2nam = c(97.5, 91.5, 83, 82.5, 
    81, 102), bio_5nam = c(314, 265.5, 311, 274, 282, 281), bio_6nam = c(167.5, 
    132.5, 175.5, 154.5, 128, 114)), .Names = c("Species", "bio_1nam", 
"bio_12nam", "bio_16nam", "bio_17nam", "bio_2nam", "bio_5nam", 
"bio_6nam"), class = "data.frame", row.names = c(NA, -6L))

prunedTargetTree <- 
structure(list(edge = structure(c(7L, 7L, 8L, 9L, 9L, 8L, 10L, 
11L, 11L, 10L, 1L, 8L, 9L, 2L, 3L, 10L, 11L, 4L, 5L, 6L), .Dim = c(10L, 
2L)), Nnode = 5L, tip.label = c("Icterus_mesomelas", "Icterus_pectoralis", 
"Icterus_graceannae", "Icterus_croconotus", "Icterus_icterus", 
"Icterus_jamacaii"), edge.length = c(0.152443952069696, 0.014866140819964, 
0.0311847312922788, 0.106393079957453, 0.106393079957453, 0.0727572150872864, 
0.0130293222294024, 0.0517912739330428, 0.0517912739330428, 0.0648205961624452
)), .Names = c("edge", "Nnode", "tip.label", "edge.length"), class = "phylo", order = "cladewise")

library(phytools)
reconBio1 <- ace(midpointData$bio_1nam, prunedTargetTree, type = "continuous", method = "ML")
bio1final <- c(reconBio1$ace, midpointData$bio_1nam)
names(bio1final) <- c(7,8,9,10,11,4,3,5,6,1,2)
plot.new()
phenogram(prunedTargetTree, bio1final, ylim = c(min(bio1final), max(bio1final)))

这是树的样子: TreeWithoutTips

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题,但是想要分享解决方案以防其他人遇到同样的问题。 pheonogram()在参数x(aka bio1final)中查找与prunedTargetTree $ tip.label匹配的名称,而不是tip的数字索引。而不是:

bio1final <- c(reconBio1$ace, midpointData$bio_1nam); 
names(bio1final) <- c(7,8,9,10,11,4,3,5,6,1,2)

应该是:

bio1final <- c(reconBio1$ace, midpointData$bio_1nam); 
names(bio1final) <- c(7,8,9,10,11,as.character(midpointData$Species))

** as.character非常重要,因为否则会将$ Species作为一个因子读入,并且树的提示仍然不会绘制。