1
0
mirror of https://github.com/msberends/AMR.git synced 2025-08-14 19:35:15 +02:00
Files
.github
R
data
data-raw
inst
man
AMR-deprecated.Rd
AMR-options.Rd
AMR.Rd
WHOCC.Rd
WHONET.Rd
ab_from_text.Rd
ab_property.Rd
add_custom_antimicrobials.Rd
add_custom_microorganisms.Rd
age.Rd
age_groups.Rd
antibiogram.Rd
antimicrobial_selectors.Rd
antimicrobials.Rd
as.ab.Rd
as.av.Rd
as.disk.Rd
as.mic.Rd
as.mo.Rd
as.sir.Rd
atc_online.Rd
av_from_text.Rd
av_property.Rd
availability.Rd
bug_drug_combinations.Rd
clinical_breakpoints.Rd
count.Rd
custom_eucast_rules.Rd
dosage.Rd
eucast_rules.Rd
example_isolates.Rd
example_isolates_unclean.Rd
export_ncbi_biosample.Rd
first_isolate.Rd
g.test.Rd
get_episode.Rd
ggplot_pca.Rd
ggplot_sir.Rd
guess_ab_col.Rd
intrinsic_resistant.Rd
italicise_taxonomy.Rd
join.Rd
key_antimicrobials.Rd
kurtosis.Rd
like.Rd
mdro.Rd
mean_amr_distance.Rd
microorganisms.Rd
microorganisms.codes.Rd
microorganisms.groups.Rd
mo_matching_score.Rd
mo_property.Rd
mo_source.Rd
pca.Rd
plot.Rd
proportion.Rd
random.Rd
resistance_predict.Rd
skewness.Rd
top_n_microorganisms.Rd
translate.Rd
pkgdown
tests
vignettes
.Rbuildignore
.gitignore
AMR.Rproj
CRAN-SUBMISSION
DESCRIPTION
LICENSE
NAMESPACE
NEWS.md
README.md
_pkgdown.yml
codecov.yml
cran-comments.md
index.md
logo.svg
AMR/man/top_n_microorganisms.Rd

48 lines
2.6 KiB
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/top_n_microorganisms.R
\name{top_n_microorganisms}
\alias{top_n_microorganisms}
\title{Filter Top \emph{n} Microorganisms}
\usage{
top_n_microorganisms(x, n, property = "fullname", n_for_each = NULL,
col_mo = NULL, ...)
}
\arguments{
\item{x}{A data frame containing microbial data.}
\item{n}{An integer specifying the maximum number of unique values of the \code{property} to include in the output.}
\item{property}{A character string indicating the microorganism property to use for filtering. Must be one of the column names of the \link{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 \code{NULL}, the raw values from \code{col_mo} will be used without transformation.}
\item{n_for_each}{An optional integer specifying the maximum number of rows to retain for each value of the selected property. If \code{NULL}, all rows within the top \emph{n} groups will be included.}
\item{col_mo}{A character string indicating the column in \code{x} that contains microorganism names or codes. Defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.}
\item{...}{Additional arguments passed on to \code{\link[=mo_property]{mo_property()}} when \code{property} is not \code{NULL}.}
}
\description{
This function filters a data set to include only the top \emph{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.
}
\details{
This function is useful for preprocessing data before creating \link[=antibiogram]{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.
}
\examples{
# 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
)
}
\seealso{
\code{\link[=mo_property]{mo_property()}}, \code{\link[=as.mo]{as.mo()}}, \code{\link[=antibiogram]{antibiogram()}}
}