KlausVigo / tanggle

phylogenetic networks using ggplot2 and ggtree
https://klausvigo.github.io/tanggle
11 stars 5 forks source link

Error reading SplitsTree output #10

Open BenAuxier opened 2 years ago

BenAuxier commented 2 years ago

Hello, I am having trouble with using tanggle on my Splitstree output. I can sucessfully plot the woodmouse data. I tried comparing my data to the woodmouse example, and I cannot see where the difference is:

splitstree1.nexus.zip

The error message I get is

net <- phangorn::read.nexus.networx("/Users/user/Downloads/splitstree1.nexus") ggsplitnet(net) Error in label[ind] <- model$translate$label : NAs are not allowed in subscripted assignments

I do not see any NAs in my data, maybe you can clarify what this error message is referring to?

KlausVigo commented 2 years ago

Hello @BenAuxier, the problem occurs as Splitstree allows tip labels to be on internal nodes (nodes with degree > 1). I did not have this on my radar and I will try to fix this in phangorn and tanggle.

KlausVigo commented 2 years ago

Hello @BenAuxier, 9160a7a should fix the bug. It is a workaround and adds additional external edges of length 0. So now all tips are now nodes of degree 1.

BenAuxier commented 2 years ago

Okay, now a slightly different problem, using the development version from remotes::install_github there are problems plotting with meta data:

fdir <- system.file("extdata/trees", package = "phangorn") samp_Nnet <- phangorn::read.nexus.networx(file.path(fdir,"woodmouse.nxs")) p <- ggsplitnet(samp_Nnet) + geom_tiplab() samp_meta_data <- data.frame("Sample ID" = samp_Nnet$tip.label, locationgroup = runif(length(samp_Nnet$tip.label))) samp_meta_data p p %<+% samp_meta_data + geom_tippoint(aes(col=locationgroup))

The first plot looks okay, but when I add the samp_meta_data the plotting goes a bit wrong

Rplot