Giter Site home page Giter Site logo

phytools's People

Contributors

josephwb avatar klausvigo avatar liamrevell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phytools's Issues

feature request-gradient information in biplot.phyl.pca

Hey @liamrevell @KlausVigo

Is it possible to add metadata information of the data in the biplot.

For example,
library(phytools)
library(coda.base)
tree<-pbtree(n=26,tip.label=LETTERS) #from biplot.phyl.pca blog plost
X<-fastBM(tree,nsim=4,bounds=c(1,10)) #bounds added to have positive values only
X2<-as.matrix(dist(X, method="aitchison")) #distance matrix in Aitchison distance
values<-as.factor(c("wood","soil")) #gradient information
Y<-as.vector(rep(values,len=nrow(X2))) #gradient information mapped on X2 matrix
obj<-phyl.pca(tree,X2) #works, gives the ordinates
biplot(obj,Y) #gives an error ofcourse

I am looking for a way to get a biplot with information of vector Y plotted on the biplot.
Any suggestions?

name of trees labeled on cophylo plot

Dear developers,
The function cophylo is quite helpful. I was just wondering whether it's possible to include an option to have the tree names automatically labeled at the two sides.

Plot phylo.heatmap and paintBranches() tree in one plot?

Hello! Is it possible to plot a tree object with painted branches using phylo.heatmap? There's no option in the current phylo.heatmap function to color branches anything other than black, and colors= is passed to the heatmap plot. My code below with the attempt, obviously not functional, at bottom.

#Read tree
extree <- rtree(n = 20)
# Make data to paint branches by
tip_data <- (sample.int(3, 20, replace = TRUE))
tip_cols <- as.data.frame(cbind(extree$tip.label,tip_data))
b <- factor(tip_cols$tip_data)
names(b) <- tip_cols$V1
present <- names(b)[b=="1"]
absent <- names(b)[b=="2"]
unknown <- names(b)[b=="3"]
#paint branches
paintedtree <- paintBranches(extree,edge=sapply(present,match,extree$tip.label),
                    state="present",anc.state="new")
paintedtree <-paintBranches(paintedtree ,edge=sapply(absent,match,extree$tip.label),
                  state="absent")
paintedtree <-paintBranches(paintedtree ,edge=sapply(unknown,match,extree$tip.label),
                  state="unknown")
cols<-setNames(c("blue","orange","gray","black"),c("present","absent","unknown","new"))
#plot the tree with colored branches
plot(textree,colors=cols,lwd=1,fsize=1)
#Make data for a heatmap
char1 <- (sample.int(3, 20, replace = TRUE))
char2 <- (sample.int(3, 20, replace = TRUE))
heatmap <- as.data.frame(cbind(char1,char2))
row.names(heatmap) <- extree$tip.label
#plot the tree with the heatmap
phylo.heatmap(extree,heatmap,fsize=1,lwd=1)
#Try to plot the painted branch tree using phylo.heatmap (obviously coloring does not work)
phylo.heatmap(paintedtree,heatmap,fsize=1,lwd=1,colors = cols)

Save a phylomorphospace3d to file Rstudio

Hello,
When I plot 3d morphospaces the plot always creates a pop-up window in Rstudio with no apparent way to export the plot to a file. Is there a way of achieving this fro the command line?

Sorry for the hassle,

Carlos

read.newick() fails to import singleton trees

read.newick() does not create a proper phylo representation for simple trees that consists of one root node and one leaf node (examples of such trees is found here: http://glottolog.org/static/trees/tree-glottolog-newick.txt). More specifically, the $edges it produces ends up to be a vector, where it should be a matrix. This can be fixed with a very simple patch. I prefer to post the patch here rather than open a pull request because this is such a minor change.

--- read.newick.R   2015-12-16 13:15:22.000000000 +0100
+++ read.newick2.R  2015-12-16 13:16:08.000000000 +0100
@@ -90,7 +90,7 @@
        }
    }
    Ntip<-k-1
-   edge<-edge[!is.na(edge[,2]),]
+   edge<-edge[!is.na(edge[,2]),,drop=F]
    edge[edge>0]<-edge[edge>0]+Ntip
    edge[edge<0]<--edge[edge<0]
    edge.length[is.na(edge.length)]<-0

adding more than one species to my tree

Hi,

I am using add.species.togenus function because i would like to add quite a lot of species to my tree.
I have different genera and I would like to know if it would be possible to do it!

Thannks a lot

adding timescale to a multiple stacked tree plot

Dear @KlausVigo @liamrevell

I was wondering if its possible to add the time scale to the tree of a multiple stacked plots.
For example, I have generated a plot similar to the blog- http://blog.phytools.org/2017/10/plottreebarplot-with-multiple-stacked.html

But when I add the "time scale" to the tree, the code doesn't give the right values, nor the right position of label "time".
code-
"par(mfg=c(1,1)) #means go back to the previous plot
axis(1,at=seq(30,150,by=50)) #run from 150mya to 30mya from left to right
mtext("time",1,at=50,line=2) #add "time" to the x-axis"

Any suggestions?
Regards
Jigyasa

Font size for the colour bar in plotBranchbyTrait

add.color.bar checks whether it has an argument fsize, and if so, uses it to scale the font of the color bar. But plotBranchbyTrait, which calls add.color.bar, is hardcoded to not pass it an fsize value. I think that could be addressed e.g. by duplicating the lines

	if(hasArg(fsize)) fsize<-list(...)$fsize
	else fsize<-1.0

from the scope of add.color.bar into the scope of plotBranchbyTrait too, and then passing fsize as an argument to the call of add.color.bar.
Thanks for the great tool!

plotbar not using arguments (while wBars do)

Hi Liam,

The plot is fine but it lacks every customization I tried, there is no font size or color adjustment.

Long post but I thought it was an issue with missing data, I just noticed this in the function

or plotTree.barplot, the only optional argument is add. Generally this should not be used; however it can be used to tell the function to draw the tree & barplot, respectively, in the next two open plotting devices - rather than creating a table of figures in the current plotting device.

Sorry

read.simmap and write.simmap are not working properly

I am attempting to save simmap simulations made by make.simmap.

When using nsim > 1, I get:
Error: evalutaion nested too deeply: infinite recursion / options(expressions=)?
Seems like some recursion is not working properly?

If using nsim = 1, it is saved. However, when I attempt to read it again (without text, I hope that code is smart enough to be able to write and read same object), I get:
Error in start:end : NA/NaN argument

The software simmap cannot be downloaded

Dear Liam,
This is a problem that has nothing to do with R code.I can't download the software from the official website of Simmap. Its official website is closed, so I would like to ask if you have the installation package of Simmap.
Thanks
Ru.

apeACE function

Hi Liam
I am trying out an analysis in phytools. I was trying to use the updated version of rerootingMethod that can account for polytomies.
http://blog.phytools.org/2015/06/update-to-rerootingmethod-for-ancestral.html
Now that function calls the function apeACE. I have first installed the latest phytools from CRAN and then changed to the github version. I found the function within R/make.simmap.R on your github page, however, I do not have it within the phytools library.
What would be the best way to proceed?
Thanks
Astrid

make.simmap appears to run slow

Dear Liam,

I have noticed that make.simmap runs slower that I expected. For example, generating 1000 mappings based on a tree with 50 taxa, using the following syntax:

mtrees<-make.simmap(tree,tree$states,model="ER", nsim=100,pi="estimated")

Took minutes. Using your suggestion in Github issue 22, running time was reduced, but I would like to avoid using parallelization.

I wonder if the long running time could be a result of not using the correction (equation 11 in Nielsen 2002) in history sampling in cases where the parent state is different from the child state. This could result in many repeated attempts to simulate a satisfactory mapping to a branch.

Could this possibly be the reason? if yes, what can I do to overcome this?

Many thanks!
Keren

Possible bug in contMap() function

Dear Liam,

Yesterday I run the contMap() function and it worked perfectly once, but later it started reporting the following error:

contTree <- contMap(rec.tree, recVec, plot = T)

Error in UseMethod("root") :
no applicable method for 'root' applied to an object of class "list"
In addition: Warning message:
In drop.tip(tree, tree$tip.label[tree$tip.label %in% nn], trim.internal = FALSE) :
drop all tips of the tree: returning NULL

Maybe it is my fault, but it looks like something happened with the funtion. If you need more information about my code please ask me and I'll provide it.

Thanks a lot in advance,

Pablo

make.simmap(): Check shape of Q matrix. And others.

Hey Liam,
nice package, fill nicely niche simmap created when it remained to be Mac only GUI only software:)

However, I have a few minor problems:
By definition, rows of Q should sum to zero. It would be nice if make.simmap checked this and reported error. I am surprised that I can do t(Q) and still get results. Even when it sometimes (but not always) throw some warning or error.

Also, it would be nice if this was commented a bit better function description. The description in arguments is very convoluted, it would be better to write something shorter and then "see more in details" and here describe all possible arguments. This way, it is big block of text, where one can see all description and it is not clear if the description is for MCMC, estimated, empirical, fixed or vQ or pi and so on.

Also, I don't want to sound too negative, but variable names like AA, XX, ZZ are quite bad:/

And another question, this is kind of R question in general. It seems that it is "traditional" in R, that functions do a lot of stuff at the same time. Personally, I would divide each function into several logical steps implemented separately. It can be then unit-tested much more easily and, someday in future, C/C++ implementation of critical parts could be added (and if large-scale simulations like in simmap are to be done, R is unable to handle this)

Thanks, I hope that I was not too negative.
Jirka

error in make.simmap when using pi argument

Hi Liam,

I am attempting to set the prior distribution on the root node of the tree, pi = c(0.66, 0.34)

Q<-matrix(c(-1,1,1,-1),2,2)
rownames(Q)<-colnames(Q)<-letters[1:2]
tree<-pbtree(n=100,scale=1)
tree<-sim.history(tree,Q)
mtrees<-make.simmap(tree,tree$states, nsim=100, model="ARD", pi = c(0.66, 0.34))

I get the error (in Spanish, sorry):
Error in getPars(bt, xx, model, Q = NULL, tree, tol, m, pi = pi, ...) :
el argumento formal "pi" concuerda con múltiples argumentos especificados

It happens since the last R update (R 3.3.3). Could that be the problem?

thank you,

Santiago

anc.ML with missing data

Dear Liam,

I'm trying to reconstruct ancestral states of genome sizes using anc.ML with an incomplete data frame (with about 26% of the tips without genome sizes available), but I'm getting the following error message:

Error in ace(x, a, method = "pic") :
length of phenotypic and of phylogenetic data do not match.
Warning message:
In mean.default(x) : argument is not numeric or logical: returning NA

Thanks in advance!

Cheers,

Santelmo.

read.newick freezes when reading newick text with one tip only

I realize this is something that most users would have rarely encounter, since most of them would certainly know how their newick string looks like before trying to read it into R. And It wouldn't make any sense trying to read a phylogeny with one tip only.
However, I discovered this behaviour when I was trying to read a bunch of newick strings I have not looked before into R. They were generated with the rphylotastic package, which basically takes a vector of taxa and subsets trees from databases by matching those taxa. Sometime only one taxon is matched in the source tree, so the subset tree looks like the following:
"Ursus_americanus;"
Then, trying to read this into a phylo object with read.newick(text = "Ursus_americanus;" freezes R.
Not a big deal, just thought it might be useful to share that this is happening.

rotate.multi in tipRotate() limited to ~12 tips per multifurcated node

Hi
I just ran into this issue while using cophylo() with a tree containing a multifurcation-node with 33 tips. The error returned is:

Error in vector("list", gamma(n + 1)) : 
  vector size specified is too large

with traceback:

4. permn(ii) 
3. rotate.multi(tree, nn[i]) 
2. tipRotate(tr1, x * Ntip(tr1)/Ntip(tr2), right = tr2, assoc = assoc, ...) 
1. cophylo(sa3int_tree, scn_tree, rotate = T, rotate.multi = T) 

It turns out that perms(ii) tries to create a vector of gamma(33+1) = 8.683318e+36 elements - too many considering that R starts using a lot of time (and memory!) with perms(n) for n > 12:

> l <- t(sapply(1:14, function(i) system.time(vector("list", gamma(i)))))
> rownames(l) <- paste("i =", 1:14)
> l
       user.self sys.self elapsed user.child sys.child
i = 1      0.000    0.000   0.000          0         0
i = 2      0.000    0.000   0.000          0         0
i = 3      0.000    0.000   0.000          0         0
i = 4      0.000    0.000   0.000          0         0
i = 5      0.000    0.000   0.000          0         0
i = 6      0.000    0.000   0.000          0         0
i = 7      0.000    0.000   0.000          0         0
i = 8      0.000    0.000   0.003          0         0
i = 9      0.000    0.000   0.000          0         0
i = 10     0.001    0.004   0.007          0         0
i = 11     0.005    0.006   0.012          0         0
i = 12     0.068    0.072   0.141          0         0
i = 13     0.933    0.876   1.809          0         0
i = 14    13.632   20.402  34.458          0         0

Is there any way around this?
I am working with trees from conserved genes, so there is many examples of nodes with many identical sequences.

Thanks a lot

Run make.simmap in parallel

It takes about 40 minutes to run one iteration of make.simmap, is it possible to run make.simmap in parallel and combine the outputs somehow? Thanks for making nice software with good documentation!

Align clade labels in phylogeny

Hello Liam and all,

I am using the cladelabels function in phytools to annotate clades in a cladogram. I want to annotate several clades but I have found difficult to have the lines (produce by cladelabels) aligned between clades. I figured this is because I am not using the 'offset' argument correctly. Is there a way to have all these perfectly aligned? This would make the figure much better. Thank you very much for your help with this.

Best,

Laura Céspedes

object 'Brazil.tree' not found?

library(viridis)
Loading required package: viridisLite
cols<-setNames(sample(viridis(n=Ntip(Brazil.tree))),

  •            Brazil.tree$tip.label)
    

Error in setNames(sample(viridis(n = Ntip(Brazil.tree))), Brazil.tree$tip.label) :
object 'Brazil.tree' not found

cophylo object doesn't plot all branches

I am plotting two trees (one with 194 taxa, the other 262) as a cophylo object. The tree compiles without errors.
The smaller tree plots correctly, but the larger one loses branches (see screenshot of partial tree below). This was using pdf()
screenshot 2017-08-30 11 20 04

Plotting directly to RStudio's graphics display produces the following
screenshot 2017-08-30 11 25 36

Do you know if this is a memory/plotting issue with R, or something to do with the code?

Error when plotting phylo.to.map

When plotting phylo to map, I get the following error:

plot(xx,type="phylogram")
Error in xy.coords(x, y) : 'x' and 'y' lengths differ

'direct' method works fine.

Some graphics are output, but the tree looks like it needs rotating 180 (see attached).
screenshot from 2016-08-22 10 39 20

Happy to send the input files if necessary via email.

Jon

scoping problem in fastAnc, phytools_reroot; breaks when latest treeio is loaded

Thanks very much for your work on this package!

Description of problem: phytools::fastAnc seems to call the function root, which appears to typically be resolved to ape::root.phylo. However, the package treeio (now necessary for using ggtree) now defines its own function root.phylo which is not compatible, and which fails if the new root is equal to ((# tips) + 1). fastAnc therefore throws a non-intuitive error if treeio is loaded. Ironically, treeio:::root.phylo actually wraps phytools::reroot, but because phytools::reroot also calls root with no scoping, it ends up circling back to treeio:::root.phylo.

Things I've tried: Manually setting root.phylo <- ape::root.phylo doesn't seem to override what happens when I call fastAnc. Loading treeio first also doesn't work.

Workaround: I don't have a good one, other than redefining fastAnc in my own package and changing the scoping.

Suggested fix: replace root with ape::root.phylo in fastAnc and reroot (and ideally also wherever else is appropriate in phytools).

Meanings of the edge numbers?

image

Work on a figure like the one shown above. Could you please tell me what does the edge number meaning? Or it's just numbers and don't mean anything? Thanks.

Small bug in make.simmap

This line in make.simmap contains a bug:

N<-length(tree$tip)

This $ selection relies on the fact that tip is matched to tip.label. This might fail if a user has edited the phylo object, for example by adding another set of tip labels with alternate naming in tree$tip.label2 (as I did).

In general it is risky to rely on automatic matching with $. I suggest the line should read

N<-length(tree[["tip.label"]])

Or better yet:

N<-ape::Ntip(tree)

Looks like the same bug as fixed in the last commit: fc70961. Searching for length(tree$tip) gives a lot of results!

plotTree.singletons and nodelabels error "last_plot.phylo" not found

Hi,

I'm facing a problem with the usage of nodelabels when used in conjunction with plotTree.singletons. My phylogenetic tree has singleton nodes, however nodelabels fails with an error message that last_plot.phylo not found. I'd really appreciate your help with solving this. My end goal is to have nodelabel plot piecharts for each of the ancestral nodes in the graph including the singleton ones.

I've attached my source code below with the necessary input data. Thanks a lot for your help.

Jaaved Mohammed
PhD student of Computational Biology
Cornell University

Data

sample.txt
sample_m.txt
sampletree.txt

Source

library(phytools)

treefilename="sampletree.txt"
evidencefilename="sample.txt"
marginalsfilename = "sample_m.txt"

cols = c("red", "green"); names(cols)<-c(0,1)
mt = read.newick(treefilename)

evidence = read.table(evidencefilename, header=T, stringsAsFactors=F, sep="\t");
evidence <- evidence[, c("dm3", "droSim2", "droSec2", "droYak3", "droEre2", "droAna3", "dp5", "droPer2", "droWil2", "droVir3", "droMoj3", "droGri2")];
rownames(evidence) <- evidence$name;


marginals = read.table(marginalsfilename, header=F, col.names = c("nodeid", "name", "zero", "one"), stringsAsFactors=F, sep="\t");
marginals = as.matrix(marginals[, c("zero", "one")]);
colnames(marginals) <- c(0, 1);

plotTree.singletons(mt);
nodelabels(pie=marginals, piecol = cols);
**Error in get("last_plot.phylo", envir = .PlotPhyloEnv) : 
  object 'last_plot.phylo' not found**
tiplabels(pie=to.matrix(evidence,seq=c(0,1)), piecol = cols,cex=0.5);

R Session Info


R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] phytools_0.5-10 maps_3.1.0      ape_3.4        

loaded via a namespace (and not attached):
 [1] quadprog_1.5-5          lattice_0.20-33         mvtnorm_1.0-5           msm_1.6                 MASS_7.3-45             grid_3.2.0              nnls_1.4               
 [8] nlme_3.1-124            magrittr_1.5            scatterplot3d_0.3-36    phangorn_2.0.2          Matrix_1.2-3            splines_3.2.0           tools_3.2.0            
[15] igraph_1.0.1            plotrix_3.6-1           parallel_3.2.0          numDeriv_2014.2-1       survival_2.38-3         mnormt_1.5-3            clusterGeneration_1.3.4
[22] animation_2.4           expm_0.999-0

Error in 'make.simmap' when 'Q="empirical"' or 'p="estimated"

This code will reproduce the error:

phytools version ‘0.5.65’, geiger version '2.0.6' and ape version '4.0'

library(phytools)
library(geiger)
tree <- sim.bdtree(stop="taxa", n=200)
trait <- rep(c("A","B"), each = 100)
names(trait) <- tree$tip.label
map1 <- make.simmap(tree, x=trait, model="ARD", message=FALSE) ## Runs ok.
map2 <- make.simmap(tree, x=trait, model="ARD", Q="empirical", message=FALSE) ## Error

Warning message: In log(comp[1:M + N]) : NaNs produced using rerootingMethod

Hi Liam
I have looked a bit more into the issue I have.
I have a rooted tree, no polytomies and a categorical character matrix in which I code states with probabilities. I then used the rerootingMethods function (the one in the current package version and the one you suggested to use in case polytomies are present and to which my google search for the error message led me).
Now, I am running the following,
anc_sp_ER <- rerootingMethod(pruned.tree, Strict_13states_matrix, type = "discrete", model = "ER", tips = TRUE)
anc_sp_SYM <- rerootingMethod(pruned.tree, Strict_13states_matrix, type = "discrete", model = "SYM", tips = TRUE)
anc_sp_ARD <- rerootingMethod(pruned.tree, Strict_13states_matrix, type = "discrete", model = "ARD", tips = TRUE)
and when I am running the SYM model I get the warning message, but not with the other models.
Any advice on this?
Thanks for your help
Astrid

problem with extract.clade.simmap

Hi,
I think there is a little bug with the function extract.clade.simmap, the returned tree has the same tree$Nnode and tree$node.label attributes as the input tree.

cophyloplot for unequal number of tip labels between two trees

Hey @liamrevell

Is it possible to plot a cophyloplot of two trees of unequal tip labels?
for example
tree1 has 10 tip.labels
tree2 has 20 tip.labels
association table will be like-
tip1--tip1
tip2--tip1
tip3--tip2
tip3
tip4
tip5--tip5

As tree2 has 20 tip.labels, I found [http://blog.phytools.org/2019/06/update-to-plotcophylo-to-permit.html] that allows duplicate matches between two trees. But in the examples used, the two trees had same number of tip labels at all times.

Thanks

reroot fails if node is set to the first internal node in edge matrix

Hi Liam,

I just came across this behaviour with reroot(). Just wondering if this is the way it is supposed to be.

library(phytools)
reroot(rtree(5), 4)   # root at leaf nodes works

reroot(rtree(5), 6)   # root at "root" node fails
# Error in UseMethod("root") : 
#  no applicable method for 'root' applied to an object of class "list"
# In addition: Warning message:
# In drop.tip(tree, tip, trim.internal = FALSE) :
# drop all tips of the tree: returning NULL

reroot(rtree(5), 7)   # root at other internal nodes works just fine
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /home/thackl/software/R-3.5.1/lib/R/lib/libRblas.so
LAPACK: /home/thackl/software/R-3.5.1/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] phytools_0.6-60 maps_3.3.0      ape_5.2        

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18            quadprog_1.5-5          lattice_0.20-35        
 [4] MASS_7.3-50             grid_3.5.1              nlme_3.1-137           
 [7] magrittr_1.5            coda_0.19-1             scatterplot3d_0.3-41   
[10] phangorn_2.4.0          combinat_0.0-8          Matrix_1.2-14          
[13] fastmatch_1.1-0         igraph_1.2.2            plotrix_3.7-3          
[16] numDeriv_2016.8-1       parallel_3.5.1          compiler_3.5.1         
[19] pkgconfig_2.0.2         mnormt_1.5-5            clusterGeneration_1.3.4
[22] animation_2.5           expm_0.999-2  

reroot() does not pass edgelabels = TRUE to root()

It seems like ape allows for specifying whether node labels specify edgelabels using edgelabels = TRUE, which is important for bootstrap values. I think the default behavior is edgelabels = FALSE. It looks like edgelabels = TRUE happens to be a setting that I wanted to set for rerooting a tree, but I was trying to use reroot in phytools to root on a branch. It looks like reroot doesn't allow passing that argument through to root.

wrong node label in drop.tip.singleton

Dear @liamrevell,

I'm using the function 'drop.tip.singleton' and having some problems with node labels. The final tree has some node labels of excluded nodes. For instance:

# Pool tree of which I want remove some tips
pool <- "((((((((annona_cacans,annona_sylvatica,annona_montana,annona_dioica,annona_coriacea,annona_cornifolia,annona_dolabripetala,annona_neosalicifolia,annona_neosericea,annona_nutans,annona_crotonifolia,annona_crassiflora)annona,(rollinia_sylvatica,rollinia_emarginata,rollinia_mucosa,rollinia_sericea)rollinia),(guatteria_australis,guatteria_nigrescens)guatteria),(duguetia_furfuracea,duguetia_lanceolata)duguetia),(xylopia_sericea,xylopia_brasiliensis,xylopia_aromatica,xylopia_emarginata)xylopia),(porcelia_macrocarpa)porcelia),((unonopsis_lindmanii)unonopsis,(ephedranthus_parviflorus)ephedranthus)),(anaxagorea_phaeocarpa)anaxagorea)annonaceae;"

# Species of my sample of which I want to keep in pool tree.
samp <- c("annona_cacans","annona_coriacea","annona_crassiflora","annona_dolabripetala","annona_neosalicifolia","annona_neosericea","annona_nutans","annona_sylvatica","duguetia_furfuracea","duguetia_lanceolata","xylopia_aromatica")

# Reading pool tree
tpool <- read.newick(text=pool)

# Removing tips of pool tree that is not in my sample
tsamp <- drop.tip.singleton(tpool, tpool$tip.label[!(tpool$tip.label %in% samp)])

# Final tree
write.tree(tsamp)
"((((((((annona_cacans,annona_sylvatica,annona_coriacea,annona_dolabripetala,annona_neosalicifolia,annona_neosericea,annona_nutans,annona_crassiflora)annona)),(duguetia_furfuracea,duguetia_lanceolata)rollinia),(xylopia_aromatica)guatteria))))annonaceae;"

Note that 'rollinia' and 'guetteria' nodes labels must be dropped, but the function changed 'duguetia' and 'xylopia' nodes labels to labels of nodes that was deleted.

Best regards,

Mario

An error when executing treeSlice()

Dear Dr. Revell,

Thanks for your great package.
I used treeSlice to Slice my tree, but meeted ERROR. I can't find how to solve the issue. Could you take time to have a look?
The followings were my commands and ERROR messages. Attached is the input file
RAxML_bipartitions.T15.txt.

require(geiger)
require(phytools)
tree = read.tree("RAxML_bipartitions.T15")
trees<-treeSlice(tree)
Error in if (nodes[i] > Ntip(tree)) { :
missing value where TRUE/FALSE needed

branch with polytomies

Hey

I am working through the contMap function and I tried all the different versions of di2multi command on my tree to remove polytomies. [https://www.r-phylo.org/wiki/HowTo/DataTreeManipulation and http://blog.phytools.org/2012/11/mapping-reconstructed-value-of.html]. But its still not resolved, and I keep getting the following error-

Error in if (x <= trans[1]) state <- names(trans)[1] else if (x >= trans[length(trans)]) state <- names(trans)[length(trans)] else { :
missing value where TRUE/FALSE needed

My codes-
termite_treerooted<-root(termite_tree, 212)
termite_tree2<-di2multi(termite_treerooted,0.03) #remove polytomies
plotTree(termite_tree2,fsize=0.6)

obj<-contMap(termite_tree2,ko_level3_nitrogen_matrix,res=200, lwd=1, outline=T, fsize= 0.3)

Any suggestions?

Problems installing in R version 3.4.1 (2017-06-30)

Hi Liam,
I am running into some issues installing from source locally (or via repository).
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
inferring 'repos = NULL' from 'pkgs'

  • installing source package ‘phytools’ ...
    ** R
    ** data
    ** inst
    ** preparing package for lazy loading
    Error : objects ‘neworder_phylo’, ‘neworder_pruningwise’ are not exported by 'namespace:ape'
    ERROR: lazy loading failed for package ‘phytools’
  • removing ‘/usr/local/lib/R/site-library/phytools’
    Warning message:
    In install.packages("/media/venezuela1/packages/phytools-master.tar.gz", :
    installation of package ‘/media/venezuela1/packages/phytools-master.tar.gz’ had non-zero exit status

There seem to be some uncommented code in neworder_phylo or neworder_pruningwise that causes installation to fail. but I am not sure what could it be.
Have you seen anything like this? I would appreciate any insight. Thanks!

Omar

Phylogenetic diversity estimate

I read an article use phytools to quantify Phylogenetic diversity by summing of branch lengths.I want to do similar work. I read https://cran.r-project.org/web/packages/phytools/phytools.pdf your instruction but I still don't know which function should I use. Could you offer a simple demo for me to follow?
Thanks in advance~

Problem with write.simmap / read.simmap

Hi, I am trying to save the trees created with make.simmap, but when I write them with write.simmap, default options, -even though I don't get any error message-, I cannot read the nexus file with read.simmap, and I get this error message:
Error in start:end : NA/NaN argument
I attached a subtree saved with write.simmap
I am running phytools v. 0.6.99
tree.test.txt

ancThresh: working example?

Dear Dr. Revell,

First off - great package. Second: where do you want issues/bugs reported? I assume here, but please redirect me if you wish to have these reported elsewhere.

THE PROBLEM: I can't seem to get the ancThresh function to work, and can't find a working example online.

TEST CODE: Below is some test code that I can't get to work - but should if I understand the function correctly:

library(phytools)
r.tree <- rtree(20)
r.states <- sample(c(0,1,2),20,replace=T)
names(r.states) <- r.tree$tip.label
# Error 1
ancThresh(r.tree,r.states,ngen=1000)
# Error 2
r.states <- as.factor(r.states)
ancThresh(r.tree,r.states,ngen=1000)

objective: 0 when running phylo.to map

Hi Liam,

I keep getting 'objective: 0' but I cannot find the problem. I'm quite sure that there's no problem with the structure or rownames.

head(site)
lat long
Ficedula narcissina 39.4834 115.25
Ficedula narcissina 39.4834 115.25
Ficedula narcissina 39.4834 115.25
Ficedula narcissina 39.4834 115.25
Ficedula narcissina 39.4834 115.25
Ficedula narcissina 39.4834 115.25
is.matrix(site)
[1] TRUE
setdiff(rownames(site), host.tree$tip.label)
character(0)
obj <- phylo.to.map(host.tree, site, database = "worldHires", plot = F)
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0
objective: 0

Hope you can give some suggestions on resolving this problem. Thanks!

tip label offset in fan projection

Hi @liamrevell,

first of all, I think phytools is great so I'm not here to complain. But there's something I can't figure out: how do I increase the spacing between the tip names and the ends of the terminal branches? I've experimented with the offset argument, in the code here: https://github.com/naturalis/trait-geo-diverse-ungulates/blob/27fdf108345a77fdba0ad55c40860e10c9c25789/script/Niche_Traits.Rmd#L189-L204 - both in the plot() call and in tiplabels() but I keep getting figures like this: https://github.com/naturalis/trait-geo-diverse-ungulates/blob/27fdf108345a77fdba0ad55c40860e10c9c25789/results/maxent/bio14_contMap.pdf

The black dot on some of the tips (or really any marker that is aesthetic) is - to my taste - a bit too close to the names. How would I change that? Or is it not an option in fan projection?

Cheers,

Rutger

make.simmap throws warning on large dataset

Hi Liam
I am using a rather large dataset (the tree has ~11600 tips) and make.simmap seems to run ok (at least it says Done) but throws this warning
Warning message: In doTryCatch(return(expr), name, parentenv, handler) : restarting interrupted promise evaluation
I can't really figure why this is happening, the phylogeny itself works fine with phytools, I am using a trait matrix with probabilities as I had before, model is ARD and nsim 1000
Any suggestions would be great.
Thanks
Astrid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.