Message Boards Message Boards

[Package] Phylogenetics for Mathematica

Dr. P. David Polly from Indiana University published a Phylogenetics package for Mathematica. A detailed User's Guide is also available. Short discription is copied below.

Keywords: Phylogenetics; Ancestral Node Reconstruction; Newick Trees

Abstract: This add-in package for Mathematica performs basic phylogenetic functions, including reading and drawing Newick format trees, calculating phylogenetically independent contrasts, reconstructing ancestral values for continuous traits, performing random walks, and simulating continuous traits on phylogenetic trees. The file is a ".m" file, which can be imported into Mathematica 6.0 and later (functions do not work in earlier versions of Mathematica). Install using the "Install" item on the "File" menu. Once installed, you must load the package like any other with the line <<PollyPhylogenetics, using either this suggested name or another.

POSTED BY: Vitaliy Kaurov
12 Replies

The structure of your tree tree is more complicated than my code expects. In addition to tips and branch lengths, your file has entries for node names. For example, one bit of the tree file looks like this:

(Belgium/ULG-6216/2020:0.03161716056206387,Ireland/Dublin-19072/2020:0.0015625157534486789)NODE_ 0000305:0.00780043233021388

That treats "Belgium/ULG-6216/2020" and "Ireland/Dublin-19072/2020" as two tips, each with a branch length after their respective ":". They are then enclosed in parentheses. What follows "NODE_0000305" appears to be a node label followed by ":" and the subtending branch length. My code is vomiting on the node name because it expects a ":" directly after the closing parenthesis (my code automatically numbers nodes using its own scheme).

You could probably strip out the node names with a search and replace for "NODE*:" to ":" if you have the right tool. Even Word will do it with the right wildcard options.

Warning though, my function is not terribly efficient. It's performance may not be great with trees this big, so expect it to be a little sluggish.

POSTED BY: P. David Polly

Hi Dr. Polly,

I'm getting some errors while trying to use a nwk file. I've tried this with PollyPhylogenetics 6.2 on Mathematica 12 and 12.1. Both failed.

This is what I get when using the Plaintext or String version of the file:

Import Errors

However, when I use an online viewer like this one http://etetoolkit.org/treeview/, it works fine:

treeviewonline

I put the data I'm trying to use in the Cloud. You can get it by doing:

CloudGet[CloudObject[https://www.wolframcloud.com/obj/christianp/Pandemic2020/data/nextstrain_ncov_timetree]]

The original source is: https://nextstrain.org/ncov

Am I doing something wrong or does the package need some update?

Thanks

There is now a phylogenetic tree plotting function in the Wolfram Function Repository.

https://resources.wolframcloud.com/FunctionRepository/resources/PhylogeneticTreePlot

It uses a particular method, and with hard-wired parameter values. So there is no flexibility for tuning. But of course the code is available in the author notebook in case people want to make alterations. Also I'd be curious to learn about experiments with different methods.

POSTED BY: Daniel Lichtblau

Yes to dependencies. One invokes as ResourceFunction["FuncName"], same as would be done anywhere else.

POSTED BY: Daniel Lichtblau

I'm eagerly waiting for the paclet repo!

Does the function repository allow dependence on other function repository functions?

POSTED BY: Szabolcs Horvát

If there are many interdependencies then it might be better to wait for the (eventual) paclet repo. But if there are useful stand-alone functions, or function grouips that have small sets of interdependencies, then the WFR is a good place from our perspective.

For what it's worth, I hope to put a phylogenenetic tree builder function there in the next several weeks. Not part of my day job, so it's not on a fast track exactly.

POSTED BY: Daniel Lichtblau

Thanks for the pointers. The page on formatting packages is particularly helpful because this information is not presented very clearly in Wolfram documentation (or if it is, I haven't found the right sections). No, I was not aware of the other phylogenetics package. It seems to have come along after I started mine and I don't think I have systematically searched for others since then.

POSTED BY: P. David Polly
Posted 5 years ago

Decent need to accomplish something like this with mine.

POSTED BY: DONN OTTO

Thank you! I used your package some years ago and was very useful. We recently released the Function Repository. Maybe you can consider submitting it there?

The function repository accepts single functions. How would a package, which contains many inter-dependent functions, fit there?

POSTED BY: Szabolcs Horvát

Thank you! I used your package some years ago and was very useful. We recently released the Function Repository. Maybe you can consider submitting it there?

Thanks for sharing!

You can consider adding your packages to http://packagedata.net/

Are you familiar with this other phylogenetics package? https://github.com/IstvanZachar/Phylogenetics

Finally, may I suggest converting it to a true package (following the standard structure, having its own context, etc.)? You will find many resources on getting started here: https://mathematica.stackexchange.com/a/132960/12

Once you are confident creating packages that follow the standard structure, you can consider distributing them as paclets: https://mathematica.stackexchange.com/q/131101/12 This provides a robust, user-friendly installation and uninstallation method.

POSTED BY: Szabolcs Horvát

A new version of Phylogenetics for Mathematica (v6.2) is available, along with user guide. The package now has more tree manipulation functions, phylogenetic comparative methods, implementation of Gene Hunt's evolutionary model fitting routines for stratigraphic sequences.

My packages Geometric Morphometrics for Mathematica, Quantitative Paleontology for Mathematica, and Modularity for Mathematica (with Anjali Goswami) are available on the same page.

The following graphic was produced using the MapTraitsOntoTree function from the Phylogenetics pacakge.

enter image description here

POSTED BY: P. David Polly
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract