Pergunta

When I generate a phenogram using the phytools package, the tips and tip labels of the trees are not displaying. Does anyone have any ideas on how to fix this, or another way of plotting a phenogram with nodes and tips with a y axis plotted at the value of the trait in question?

Here's what I have:

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)))

Here's what the tree looks like: TreeWithoutTips

Foi útil?

Solução

I have solved the problem, but wanted to share the solution in case others run into the same issue. pheonogram() looks for names in the argument x (aka bio1final) that match prunedTargetTree$tip.label, not the numeric index of the tip. Instead of:

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

it should read:

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

**as.character is important, because otherwise $Species is read in as a factor, and the tips of the tree still won't plot.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top