taxonomy icon indicating copy to clipboard operation
taxonomy copied to clipboard

working on a new SoilTaxonomy package

Open dylanbeaudette opened this issue 6 years ago • 5 comments

New SoilTaxonomy package for interacting with one of the most widely used systems of soil classification. The package is quite sparse at the moment. Long-term goals include:

  • human/machine readable hierarchy
  • dictionaries of formative elements
  • data.tree access to the hierarchy
  • methods for parsing / validating taxa
  • graphical exploration

We would like to adopt some of the practices used in other ropensci-sponsored "taxonomy" packages.

dylanbeaudette avatar Apr 03 '19 16:04 dylanbeaudette

thanks for this @dylanbeaudette

I had originally envisioned this as just biological taxonomy, but i think it makes sense to expand it. Note also that I don't have any plans to get this on CRAN's task views.

one thing that comes to mind is you could look at the taxa package to see if you could use it. Zach who maintains it has demonstrated uses for non biological taxonomy things, @zachary-foster where are those egs?

sckott avatar Apr 05 '19 17:04 sckott

You can see an example here. An encoded soil taxonomy would be great to have available. I was just searching around the internet and I can not find a simple spreadsheet with all of the soil classifications (e.g. Ultisols; Aquults;Plinthaquults;Kandic). If you had a table with all the soil types, with one column for each of Order, Suborder, Great Group, Subgroup etc, you could easily use it in taxa and plot it with metacoder or I could make a function to convert the data type so you could plot it with ggtree.

zachary-foster avatar Apr 05 '19 19:04 zachary-foster

Thanks for the feedback!

The ST data object in the SoilTaxonomy package contains exactly that. I just tried this:

library(SoilTaxonomy)
library(metacoder)

# unique taxa
data("ST", package = 'SoilTaxonomy')

# convert to Taxmap class
x <- parse_tax_data(ST, class_cols = names(ST), named_by_rank = TRUE)

# what does this do?
heat_tree(x)

Neat! There are 12 "things", which makes sense given than there are 12 soil order, the top of the hierarchy.

image

dylanbeaudette avatar Apr 05 '19 19:04 dylanbeaudette

Cool! That was fast. heat_tree plots taxonomic trees with color and shape representing some per-taxon statistic of interest. Try this out to get an idea:

library(metacoder)
x <- parse_tax_data(ST, class_cols = names(ST), named_by_rank = TRUE)

x %>% 
  filter_taxa(taxon_names == "vertisols", subtaxa = TRUE) %>%
  heat_tree(node_label = taxon_names,
            node_size = n_obs, 
            node_color = n_obs,
            node_color_axis_label = "Number of subgroups",
            output_file = "vertisols_tree.pdf")

set.seed(4)
x %>% 
  filter_taxa(!is_leaf) %>%
  heat_tree(node_label = taxon_names,
            node_size = n_obs, 
            node_color = n_obs,
            tree_label = taxon_names,
            node_color_axis_label = "Number of subgroups",
            layout = "da",
            output_file = "soil_tree.pdf")

vertisols_tree.pdf

soil_tree.pdf

zachary-foster avatar Apr 05 '19 22:04 zachary-foster

That is some seriously cool stuff! Thanks.

I'll have to read the documentation, the taxa and metacoder syntax is still quite new to me. Long-term, I would like to use whatever I can from mature packages like these so that I don't end up re-inventing the wheel. Do you have some suggestions for getting started with simple operations such as locating levels within a taxonomy, finding sub/super taxa, and so on?

The full hierarchy of Soil Taxonomy is much deeper than the four levels available in the ST object. For example, you can see some of the levels below the subgroup typic haploxerepts. That visualization is part of SoilWeb Series Data Explorer. When encoded as a data.tree object, the full hierarchy is quite large and hard to work with.

Anyways, we are still at the early stages of this package and what it can / should do. I'm eager to learn more from you all.

Dylan

dylanbeaudette avatar Apr 05 '19 22:04 dylanbeaudette