hmorlon / PANDA.jl

Phylogenetic ANalyses of DiversificAtion (in Julia)
MIT License
10 stars 1 forks source link

R output not properly formatted #13

Closed tillepprecht closed 2 years ago

tillepprecht commented 2 years ago

I believe there is a minor issue with the function that exports the results of a ClaDS run to R.

Namely, some of the variables within the phylo objects you export differ from what Ape usually calls them. This doesn't seem to cause issues when just plotting the results with functions from ape, but other packages, like "ggtree" can't work with your phylo objects.

Your phylo object:

CladsOutput$tree
     $edge
     $Nnode
     $edge.lengths
     $tip.labels

phylo object created by ape

tree
     $edge
     $tip.label
     $Nnode
     $edge.length

This is not a big issue, as the tree can just be reimported from the newick file, but with the phylo objects in CladsOutput$enhanced_trees, this is not really an option. By generating a tree with ape using rtree and then assigning the values from your trees to this tree, everything works, but it's not the nicest workaround.

Steps to reproduce:

#Install ggtree in R (https://bioconductor.org/packages/release/bioc/html/ggtree.html)
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("ggtree")
library(ggtree)

load("clads_output.RData") #Import output from Julia Clads into R

g = ggtree(CladsOutput$tree)
plot(g) #Try to plot tree using ggtree / ggplot2

I'm guessing this is easily fixed by changing the respective variable names in src/clads/export_in_R.jl Line 13, but I'm not good with Julia so I haven't tried to fix it there.

Sidenote: In your installation instructions, you say R packages need to be installed with

install.packages("ape", "coda", "RColorBrewer", "fields")

This line doesn't work, it needs to be

install.packages(c("ape", "coda", "RColorBrewer", "fields"))

Otherwise, R will try to use "coda" as the library install location, which doesn't work.

OdileMaliet commented 2 years ago

Thank you, I just modified this, it shoud now be fixed