-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New function(s) to add taxa to a taxonomy #172
Comments
good idea. is there a way to do this now? and are you talking about the object |
For
I was just thinking about |
So right now, someone would need to e.g., recreate the entire |
That would perhaps be the least error-prone way to do it for One could modify an object in place as well, but it could be tricky: > library(taxa)
> ex_taxonomy
<Taxonomy>
9 taxa: b. Mammalia, c. Notoryctidae, d. Felidae ... h. Notoryctes typhlops, i. Puma concolor, j. Panthera tigris
9 edges: NA->b, b->c, b->d, c->e, d->f, d->g, e->h, f->i, g->j
> print_tree(ex_taxonomy)
Mammalia
├─Notoryctidae
│ └─Notoryctes
│ └─Notoryctes typhlops
└─Felidae
├─Puma
│ └─Puma concolor
└─Panthera
└─Panthera tigris
> ex_taxonomy$taxa <- c(ex_taxonomy$taxa, new_id = taxon("new_taxon"))
> ex_taxonomy$edge_list <- rbind(ex_taxonomy$edge_list, c("b", "new_id"))
> ex_taxonomy
<Taxonomy>
10 taxa: b. Mammalia, c. Notoryctidae, d. Felidae ... i. Puma concolor, j. Panthera tigris, new_id. new_taxon
10 edges: NA->b, b->c, b->d, c->e, d->f, d->g, e->h, f->i, g->j, b->new_id
> print_tree(ex_taxonomy)
Mammalia
├─Notoryctidae
│ └─Notoryctes
│ └─Notoryctes typhlops
├─Felidae
│ ├─Puma
│ │ └─Puma concolor
│ └─Panthera
│ └─Panthera tigris
└─new_taxon |
Definitely seems like a pain point that we should sort out |
Also, could add a function called |
add_taxon(obj, new_taxon, supertaxon = NULL, subtaxa = NULL)
Adds
new_taxon
toobj
taxonomy.supertaxon
andsubtaxa
would accept existing taxon IDs.supertaxon = NULL
andsubtaxa
is used: New taxon is added between the subtaxa and the existing supertaxon that contains all of the subtaxasupertaxon
is used andsubtaxa = NULL
New taxon is added within the existing supertaxon. Existing subtaxa of the existing supertaxon are not affected.supertaxon
is used andsubtaxa
is used: Connects existing supertaxa with existing subtaxa, with the new taxon in between.supertaxon = NULL
and andsubtaxa = NULL
: Added as a root with no subtaxa and prints a warning/message.Alternatively, there could be three separate functions corresponding to the top three points above:
add_supertaxon
add_subtaxa
/add_subtaxon
insert_taxon
Thoughs @sckott? It seems like there could be a few ways to do implement a function to add taxa and I am not sure what would be best.
The text was updated successfully, but these errors were encountered: