Friday, June 3, 2011

searching ITIS and fetching Phylomatic trees

I am writing a set of functions to search ITIS for taxonomic information (more databases to come) and functions to fetch plant phylogenetic trees from Phylomatic. Code at github.

Also, see the examples in the demos folder on the Github site above.



# A species list, which ecologies often have, but may not know the family names, or if they do,
# they (meaning me) may spell the names wrong from time to time
> splist <- c("annona_cherimola", 'annona_muricata', "quercus_robur",
"shorea_robusta", "pandanus_patina", "oryza_sativa", "durio_zibethinus",
"rubus_ulmifolius", "asclepias_curassavica", "pistacia_lentiscus")
# Get the Taxonomic Serial Number for each species, which are unique (note that there could be many TSN's within a species
# for each subspecies for example. So you may want to query for you species using get_itis_xml in the demos on the github
# site and then make sure you get the TSN for the right subspecies or species
> tsns <- laply(splist, get_tsn, searchtype = "sciname", by_ = "name",
.progress = "text")
|===========================================================================================| 100%
# Get Phylomatic formatted strings for each species (e.g., family/genus/genus_epithet)
> dat_ <- laply(tsns, get_phymat_format, format='rsubmit', .progress="text")
|===========================================================================================| 100%
# Send the strings to Phylomatic website via an API, and retrieve the newick tree (alternatively, get xml output)
> tree <- get_phylomatic_tree(dat_, 'TRUE', 'GET', 'new', 'TRUE')
Loading required package: ape
# Plot the tree, or do anything else you want to do!
> plot(tree)






No comments:

Post a Comment