gastonstat / arcdiagram

R package arcdiagram
78 stars 38 forks source link

Phylogeny side by side with the arcdiagram? #3

Open daijiang opened 10 years ago

daijiang commented 10 years ago

Hi Gaston, Thanks for this nice package!

Suppose nodes in the arcdiagram are species and we have a phylogeny for these species. I wonder how hard it is to plot the phylogeny under the nodes if horizontal = TRUE and side by side if horizontal =FALSE? By doing this, we can have both the interaction information and their evolutionary history in the same plot. It will be great feature to have.

For plotting the phylogeny, I am using plot.phylo() function in the picante package. But I did not figure out a way to align the phylo plot and the arcdiagram.

Thanks! Daijiang

holmrenser commented 10 years ago

I am actually doing the same thing. I managed to plot phylogeny and arcdiagram side-by-side, but it would be nicer if we were able to specify xlim and ylim in the arcplot function.

jmpowers commented 9 months ago

This was fixed by @holmrenser with pull request #4

You can now set ylim to the coordinates of the top and bottom nodes (when vertical) to match the y coordinates of a phylogenetic tree:

ntaxa <- 10
pairtree <- ape::rtree(ntaxa)
par(mfrow = c(1, 2))
ape::plot.phylo(pairtree, align.tip.label = TRUE)
arcdiagram::arcplot(edgelist = matrix(paste0("t", 1:ntaxa), ncol = 2, byrow = TRUE),
                    show.labels = FALSE, horizontal = FALSE, ordering = pairtree$tip.label,
                    ylim = range(arcdiagram::xynodes(ntaxa, 1:ntaxa, labels = 1:ntaxa)))