University of California, Davis

Category: scripts

Woodchipper – a script for breaking phylogenetic trees into subclades

Here’s a handy little Perl script I wrote that takes a nexus formatted tree file and breaks down every tree that it finds into the clades that it is composed of (i.e., every node in the starting tree is returned as a new tree). It spits all of these out into a text file, which can then be copied and pasted into a tree block.

Each tree in the original file gets its own text file, named woodchipper_treename.tre, where “treename” is the name of the tree given in the trees block in the input file.

It hasn’t been tested exhaustively yet, so please check the results and contact me if you run into any trouble. No warranty is expressed or implied, your mileage may vary, not valid where prohibited, and all that.

NOTE: If you’re having trouble saving the link above, try right click -> save as instead of clicking on it in the normal way.

Datamuncher – a handy tool for niche and distribution modelers

Here’s a little tool I whipped together for my own use. I hope it’s useful to others as well. Basically what it does is take .csv files of species occurrences and a batch of ASCII files, and converts them into three output files. They are:

  1. A community presence/absence matrix, with “community” defined as a grid cell in the ASCII raster files.
  2. A set of coordinates for each grid cell that has at least one species present in it, corresponding to the “communities” above.
  3. A matrix of values from the ASCII raster files for each community.

The general idea is to take data in a format that is acceptable for Maxent (.csv and .asc) and convert it into a set of files that are usable with some of the R algorithms. Currently it seems to be working with GDM, but I haven’t tried anything else. You may need to delete columns 1-3 in the environment file, depending on what you’re doing with it.

Here’s the quick and dirty of it:

Where it says “occurrence files”, you just hit the “add files” button and drop in all of the .csv files you want to use. Note that everything in that box is going to be thrown into ONE set of output files!

Second, you add your environmental layers. ASCII raster format is the only one it understands.

Third, pick an output directory.

Finally, name your analysis. If your analysis is named “my_stuff”, the output files will be “my_stuff_communities.csv” (1 above), “my_stuff_community_coordinates.csv” (2), “my_stuff_environment.csv” (3), all dropped into the output directory you chose.

In addition to its original intent, this tool may also be useful to those who want a quick and dirty way to get their data extracted for a MANOVA or other analysis – if you feed it occurrence files for one species at a time, the environment file will contain all conditions occupied by that species. Neat!

You can download it as a Windows executable file here, or as a Perl script>here. Be aware that the Perl script requires that Tk be installed (NOT Tk+!), which you can do from the package manager. Also be aware that it probably won’t work on a Mac because of the way it’s parsing directories. If anyone wants a Mac version, please feel free to email me.

Also let me know if you hit any snags. Testing has been rather limited so far, as I just finished it today. Use at your own risk!

© 2024 Wainwright Lab

Theme by Anders NorenUp ↑