YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

added support for multiple trees / writing phylo objects in write.beast #113

Closed brj1 closed 5 months ago

brj1 commented 11 months ago

Description

I decided to add support for writing multiple trees in write.beast and support for phylo objects and lists of phylo objects.

I also added support for pulling the tree names from names(treedata). As such, I changed tree.name = "UNTITLED" to tree.name = NULL to make it use names(treedata) by default. If names(treedata) is NULL then it will use "UNTITLED" for the tree names. Setting tree.name to a vector will pull tree names from the vector.

I also changed read.beast to preserve the tree names. This is actually done by ape::read.nexus but it is not carried over to the output of read.beast. I think you are working on rewriting read.beast so this might be moot.

Related Issue

fix #39

Example

write.beast(lapply(seq_len(10), function(x) rtree(10)))

Lastly, I tested this on snippets of beast runs I had lying around, but I think it should be tested more before being pulled.

EDIT: the rexports.Rd file might not need to be changed. I think Rstudio or roxygen just decided to reorder the exports.

brj1 commented 11 months ago

I noticed a small bug in my PR in that for single trees it would grab the names of the tree object (edge, tip.label, edge.length, Ntip, etc). So I removed that from my code. I have squashed the commits into one and it is fixed here.

GuangchuangYu commented 5 months ago

thanks @brj1