user2406056
user2406056

Reputation: 49

R: Associate values to tips in phylogeny

I have a phylogeny and some data (traits values). I've reconstructed trait values for all nodes using ace in caper.

I used makeNodeLabel in ape to associate the reconstructed trait values with their appropriate nodes.

What I want to do is to export a nexus file (phylogeny) from R that contains both the node values (recontructed values) and the tip labels (emperical data).

I want to use color codes (in FigTree) to indicate the values, but right now I'm only able to do this with nodes, i.e. the tip-branches do not have data and are hence not "color codable".

I need to associate values to the tips in order to do this, but I haven't been able to figure out how to do this. I also need all the data I associate to the phylogeny to be in a "similar category", i.e. similarly to for example how theta values from *BEAST are coded in nexus files.

Any and all help is greatly appreciated.

Upvotes: 1

Views: 1038

Answers (2)

James Gao
James Gao

Reputation: 3

You could have a try 'phytools' package in the R. The function 'plotTree.wBars' could be conducted. Best wishes.

Upvotes: 0

user2406056
user2406056

Reputation: 49

I've found a workaround:

Export a tree (nexus format) from R with reconstructed traits associated to the nodes. Open in FigTree and define the "label" trait as "trait". Import tip annotations from a text file which contain empirical data in a column with the header "trait". Then export the tree from FigTree to a new file with nexus-block and include annotations. Lasty, copy names from the name block in the nexus file (animal/organism[&Trait=2.35754]) and exchange the names with the ones in the coded tree. You will then have trait values coded through [&Trait=value] for both nodes and tips. Now you can color code the entire tree which includes the empirical values that are now associated to the tips of the phylogeny.

Sooo, that's a stupid way of doing it. If anyone has a better way, I'd love to hear it.

Upvotes: 1

Related Questions