metacoder (version 0.3.7)

arrange_taxa: Sort the edge list of [taxmap()] objects

Description

Sort the edge list and taxon list in [taxonomy()] or [taxmap()] objects. See [dplyr::arrange()] for the inspiration for this function and more information. Calling the function using the `obj$arrange_taxa(...)` style edits "obj" in place, unlike most R functions. However, calling the function using the `arrange_taxa(obj, ...)` imitates R's traditional copy-on-modify semantics, so "obj" would not be changed; instead a changed version would be returned, like most R functions.


obj$arrange_taxa(...)
arrange_taxa(obj, ...)

Value

An object of type [taxonomy()] or [taxmap()]

Arguments

obj

[taxonomy()] or [taxmap()]

...

One or more expressions (e.g. column names) to sort on. Any variable name that appears in [all_names()] can be used as if it was a vector on its own.

See Also

Other taxmap manipulation functions: arrange_obs(), filter_obs(), filter_taxa(), mutate_obs(), sample_frac_obs(), sample_frac_taxa(), sample_n_obs(), sample_n_taxa(), select_obs(), transmute_obs()

Examples

Run this code
# Sort taxa in ascending order
arrange_taxa(ex_taxmap, taxon_names)

# Sort taxa in decending order
arrange_taxa(ex_taxmap, desc(taxon_names))

# Sort using an expression. List genera first.
arrange_taxa(ex_taxmap, taxon_ranks != "genus")

Run the code above in your browser using DataLab