Open brendanf opened 5 years ago
Hello @brendanf.
Adding an argument to assign the ranks when parsing using extract_tax_data
is a good idea. I will look into that. Thanks!
In regards to taxon_ranks() <-
: We are working on adding getter/setters for things like taxon ranks, but it is part of a larger rewrite of some of the code, so those additions are not in the master branch yet. If you want to try out what we are working on, you can install the eval
branch like so:
devtools::install_github("ropensci/taxa@eval")
Then, this works:
library(taxa)
taxdata <-
c("Root;Fungi;Basidiomycota;Agaricomycetes;Hymenochaetales;Hymenochaetaceae;Fuscoporia",
"Root;Fungi;Basidiomycota;Microbotryomycetes;Microbotryales;Microbotryaceae;Microbotryum",
"Root;Fungi;Ascomycota;Dothideomycetes;Botryosphaeriales;Botryosphaeriaceae;Microdiplodia")
tax <- parse_tax_data(taxdata, class_sep = ";")
my_ranks <- c("rootrank", "kingdom", "phylum", "class", "order", "family", "genus")
taxon_ranks(tax) <- my_ranks[n_supertaxa(tax) + 1]
taxon_ranks(tax)
#> b c d e f g
#> "rootrank" "kingdom" "phylum" "phylum" "class" "class"
#> h i j k l m
#> "class" "order" "order" "order" "family" "family"
#> n o p q
#> "family" "genus" "genus" "genus"
Created on 2019-04-15 by the reprex package (v0.2.1)
I have a delimited classification with set ranks, of the form
[rootrank];[kingdom];[phylum];[class];[order];[family];[genus]
, e.g.,Root;Fungi;Ascomycota;Eurotiomycetes;Eurotiales;Trichocomaceae;Hamigera
. I can parse this into aTaxonomy
usingextract_tax_data()
, but I'm not sure if/how I can assign the ranks. It would be nice if I could supplyc('rootrank', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus')
as an argument toextract_tax_data()
, but there doesn't seem to be any relevant argument.taxon_ranks() <-
doesn't seem to be defined either.I've accomplished my goal here (using
parse_tax_data()
to simplify the reprex), but it seems needlessly complex for what must be a fairly common operation: