nexml_drop | R Documentation |
nexml_drop_otu
drops OTUs (taxa) from a nexml object.
Currently none of the OTUs to be dropped can be used in a tree that's part
of the nexml
object. If they are, first drop the OTUs from the tree(s)
(for example, using drop.tip() from package "ape"), then
replace the tree(s). Dropping OTUs will not only drop them from the OTUs
block, but will also drop matrix rows that referenced the OTUs to be dropped.
This may in turn leave some characters unused. Therefore, it is recommended
to drop unused characters afterwards.
nexml_drop_char
drops characters from a nexml object. Note
that dropping characters may make some OTUs unused if they result in empty
rows and empty rows are pruned (see parameter pruneRows
). It is therefore
recommended to drop unused OTUs afterwards.
is_unused_char
is a filter function for nexml_drop_char
for dropping
unused characters.
is_unused_otu
is a filter function for nexml_drop_otu
for dropping
unused OTUs.
nexml_drop_otu(nexml, filter, at = NA, block = 1, ...)
nexml_drop_char(
nexml,
filter,
at = NA,
block = 1,
...,
pruneStates = TRUE,
pruneRows = TRUE
)
is_unused_char(charList, ...)
is_unused_otu(otuList, ...)
nexml |
the nexml object from which to drop parts |
filter |
logical, or a function returning a logical. If the latter,
it will be passed the list of selected values for filtering (see parameter
|
at |
character, selects the values for filtering if |
block |
integer, the respective block index (for OTUs and character blocks, respectively). |
... |
for For
|
pruneStates |
logical, whether to also prune (i.e., drop) states that are no longer used after dropping the selected characters. The default is TRUE. |
pruneRows |
logical, whether to also prune (i.e., drop) matrix rows that have become empty (i.e., have no cells left) after dropping the selected characters. The default is TRUE. |
charList |
a list of |
otuList |
a list of |
The functions for dropping components return a nexml object with the filtered components dropped.
is_unused_char
returns a logical vector with TRUE for each char
(character) object that is not used in the matrix (or matrices) of the
characters block(s), and FALSE otherwise.
is_unused_otu
returns a logical vector with TRUE for each otu
object that is not used in either the matrix (or matrices) of the characters
block(s), or, unless ignoreTrees = TRUE
, for a node of a tree, and FALSE
otherwise.
nex <- RNeXML::nexml_read(system.file("examples", "ontotrace-result.xml", package = "rphenoscape"))
# drop by label matching
nexml_drop_otu(nex, filter = function(x) grepl(" sp.", x), at = "label")
# can pipe dropping and then removing potentially unused characters or OTUs:
library(dplyr)
nexml_drop_char(nex, filter = function(x) grepl("pelvic", x), at = "label") %>%
nexml_drop_otu(filter = is_unused_otu)
## Not run:
nex <- get_ontotrace_data(taxon = "Ictaluridae",
entity = "fin", variable_only = FALSE)
# ontotrace results store VTO IRIs in dwc:taxonID annotations:
nexml_drop_otu(nex,
filter = function(x) !is_descendant("Ictalurus", x),
at = "dwc:taxonID") %>%
nexml_drop_char(filter = is_unused_char)
# anatomy IRIs are in obo:IAO_0000219 ("denotes") annotations:
nexml_drop_char(nex,
filter = function(x)
!is_descendant("paired fin", x, includeRels = "part_of"),
at = "obo:IAO_0000219") %>%
nexml_drop_otu(filter = is_unused_otu)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.