View source: R/top_n_microorganisms.R
top_n_microorganisms | R Documentation |
This function filters a data set to include only the top n microorganisms based on a specified property, such as taxonomic family or genus. For example, it can filter a data set to the top 3 species, or to any species in the top 5 genera, or to the top 3 species in each of the top 5 genera.
top_n_microorganisms(x, n, property = "fullname", n_for_each = NULL,
col_mo = NULL, ...)
x |
a data frame containing microbial data |
n |
an integer specifying the maximum number of unique values of the |
property |
a character string indicating the microorganism property to use for filtering. Must be one of the column names of the microorganisms data set: "mo", "fullname", "status", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "rank", "ref", "oxygen_tolerance", "source", "lpsn", "lpsn_parent", "lpsn_renamed_to", "mycobank", "mycobank_parent", "mycobank_renamed_to", "gbif", "gbif_parent", "gbif_renamed_to", "prevalence", or "snomed". If |
n_for_each |
an optional integer specifying the maximum number of rows to retain for each value of the selected property. If |
col_mo |
A character string indicating the column in |
... |
Additional arguments passed on to |
This function is useful for preprocessing data before creating antibiograms or other analyses that require focused subsets of microbial data. For example, it can filter a data set to only include isolates from the top 10 species.
mo_property()
, as.mo()
, antibiogram()
# filter to the top 3 species:
top_n_microorganisms(example_isolates,
n = 3
)
# filter to any species in the top 5 genera:
top_n_microorganisms(example_isolates,
n = 5, property = "genus"
)
# filter to the top 3 species in each of the top 5 genera:
top_n_microorganisms(example_isolates,
n = 5, property = "genus", n_for_each = 3
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.