mirror of https://github.com/msberends/AMR.git
documentation
This commit is contained in:
parent
e4ea96cbf9
commit
77d9cf1936
|
@ -1,5 +1,5 @@
|
||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.8.2.9075
|
Version: 1.8.2.9076
|
||||||
Date: 2022-12-30
|
Date: 2022-12-30
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
|
|
2
NEWS.md
2
NEWS.md
|
@ -1,4 +1,4 @@
|
||||||
# 1.8.2.9075
|
# 1.8.2.9076
|
||||||
|
|
||||||
*(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)*
|
*(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)*
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@
|
||||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
#' Mean AMR Distance
|
#' Calculate the Mean AMR Distance
|
||||||
#'
|
#'
|
||||||
#' This function calculates a normalised mean for antimicrobial resistance between multiple observations.
|
#' Calculates a normalised mean for antimicrobial resistance between multiple observations, to help to identify similar isolates without comparing antibiograms by hand.
|
||||||
#' @param x a vector of class [rsi][as.rsi()], [rsi][as.rsi()] or [rsi][as.rsi()], or a [data.frame] containing columns of any of these classes
|
#' @param x a vector of class [rsi][as.rsi()], [rsi][as.rsi()] or [rsi][as.rsi()], or a [data.frame] containing columns of any of these classes
|
||||||
#' @param ... variables to select (supports tidy selection such as `column1:column4` and [`where(is.mic)`][tidyselect::language]), and can thus also be [antibiotic selectors][ab_selector()]
|
#' @param ... variables to select (supports [tidyselect language][tidyselect::language] such as `column1:column4` and `where(is.mic)`, and can thus also be [antibiotic selectors][ab_selector()]
|
||||||
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant), defaults to `TRUE`
|
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant), defaults to `TRUE`
|
||||||
#' @details The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand. For common numeric data this distance is equal to [Z scores](https://en.wikipedia.org/wiki/Standard_score) (the number of standard deviations from the mean).
|
#' @details The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand. For common numeric data this distance is equal to [Z scores](https://en.wikipedia.org/wiki/Standard_score) (the number of standard deviations from the mean).
|
||||||
#'
|
#'
|
||||||
|
@ -83,20 +83,20 @@ mean_amr_distance <- function(x, ...) {
|
||||||
UseMethod("mean_amr_distance")
|
UseMethod("mean_amr_distance")
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mean_amr_distance
|
#' @noRd
|
||||||
#' @export
|
#' @export
|
||||||
mean_amr_distance.default <- function(x, ...) {
|
mean_amr_distance.default <- function(x, ...) {
|
||||||
x <- as.double(x)
|
x <- as.double(x)
|
||||||
(x - mean(x, na.rm = TRUE)) / stats::sd(x, na.rm = TRUE)
|
(x - mean(x, na.rm = TRUE)) / stats::sd(x, na.rm = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mean_amr_distance
|
#' @noRd
|
||||||
#' @export
|
#' @export
|
||||||
mean_amr_distance.mic <- function(x, ...) {
|
mean_amr_distance.mic <- function(x, ...) {
|
||||||
mean_amr_distance(log2(x))
|
mean_amr_distance(log2(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mean_amr_distance
|
#' @noRd
|
||||||
#' @export
|
#' @export
|
||||||
mean_amr_distance.disk <- function(x, ...) {
|
mean_amr_distance.disk <- function(x, ...) {
|
||||||
mean_amr_distance(as.double(x))
|
mean_amr_distance(as.double(x))
|
||||||
|
|
|
@ -21,7 +21,7 @@ g.test(x, y = NULL, p = rep(1/length(x), length(x)), rescale.p = FALSE)
|
||||||
\item{y}{a numeric vector; ignored if \code{x} is a matrix. If
|
\item{y}{a numeric vector; ignored if \code{x} is a matrix. If
|
||||||
\code{x} is a factor, \code{y} should be a factor of the same length.}
|
\code{x} is a factor, \code{y} should be a factor of the same length.}
|
||||||
|
|
||||||
\item{p}{a vector of probabilities of the same length as \code{x}.
|
\item{p}{a vector of probabilities of the same length of \code{x}.
|
||||||
An error is given if any entry of \code{p} is negative.}
|
An error is given if any entry of \code{p} is negative.}
|
||||||
|
|
||||||
\item{rescale.p}{a logical scalar; if TRUE then \code{p} is rescaled
|
\item{rescale.p}{a logical scalar; if TRUE then \code{p} is rescaled
|
||||||
|
|
|
@ -2,22 +2,13 @@
|
||||||
% Please edit documentation in R/mean_amr_distance.R
|
% Please edit documentation in R/mean_amr_distance.R
|
||||||
\name{mean_amr_distance}
|
\name{mean_amr_distance}
|
||||||
\alias{mean_amr_distance}
|
\alias{mean_amr_distance}
|
||||||
\alias{mean_amr_distance.default}
|
|
||||||
\alias{mean_amr_distance.mic}
|
|
||||||
\alias{mean_amr_distance.disk}
|
|
||||||
\alias{mean_amr_distance.rsi}
|
\alias{mean_amr_distance.rsi}
|
||||||
\alias{mean_amr_distance.data.frame}
|
\alias{mean_amr_distance.data.frame}
|
||||||
\alias{amr_distance_from_row}
|
\alias{amr_distance_from_row}
|
||||||
\title{Mean AMR Distance}
|
\title{Calculate the Mean AMR Distance}
|
||||||
\usage{
|
\usage{
|
||||||
mean_amr_distance(x, ...)
|
mean_amr_distance(x, ...)
|
||||||
|
|
||||||
\method{mean_amr_distance}{default}(x, ...)
|
|
||||||
|
|
||||||
\method{mean_amr_distance}{mic}(x, ...)
|
|
||||||
|
|
||||||
\method{mean_amr_distance}{disk}(x, ...)
|
|
||||||
|
|
||||||
\method{mean_amr_distance}{rsi}(x, ..., combine_SI = TRUE)
|
\method{mean_amr_distance}{rsi}(x, ..., combine_SI = TRUE)
|
||||||
|
|
||||||
\method{mean_amr_distance}{data.frame}(x, ..., combine_SI = TRUE)
|
\method{mean_amr_distance}{data.frame}(x, ..., combine_SI = TRUE)
|
||||||
|
@ -27,7 +18,7 @@ amr_distance_from_row(amr_distance, row)
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{x}{a vector of class \link[=as.rsi]{rsi}, \link[=as.rsi]{rsi} or \link[=as.rsi]{rsi}, or a \link{data.frame} containing columns of any of these classes}
|
\item{x}{a vector of class \link[=as.rsi]{rsi}, \link[=as.rsi]{rsi} or \link[=as.rsi]{rsi}, or a \link{data.frame} containing columns of any of these classes}
|
||||||
|
|
||||||
\item{...}{variables to select (supports tidy selection such as \code{column1:column4} and \code{\link[tidyselect:language]{where(is.mic)}}), and can thus also be \link[=ab_selector]{antibiotic selectors}}
|
\item{...}{variables to select (supports \link[tidyselect:language]{tidyselect language} such as \code{column1:column4} and \code{where(is.mic)}, and can thus also be \link[=ab_selector]{antibiotic selectors}}
|
||||||
|
|
||||||
\item{combine_SI}{a \link{logical} to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant), defaults to \code{TRUE}}
|
\item{combine_SI}{a \link{logical} to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant), defaults to \code{TRUE}}
|
||||||
|
|
||||||
|
@ -36,7 +27,7 @@ amr_distance_from_row(amr_distance, row)
|
||||||
\item{row}{an index, such as a row number}
|
\item{row}{an index, such as a row number}
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
This function calculates a normalised mean for antimicrobial resistance between multiple observations.
|
Calculates a normalised mean for antimicrobial resistance between multiple observations, to help to identify similar isolates without comparing antibiograms by hand.
|
||||||
}
|
}
|
||||||
\details{
|
\details{
|
||||||
The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand. For common numeric data this distance is equal to \href{https://en.wikipedia.org/wiki/Standard_score}{Z scores} (the number of standard deviations from the mean).
|
The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand. For common numeric data this distance is equal to \href{https://en.wikipedia.org/wiki/Standard_score}{Z scores} (the number of standard deviations from the mean).
|
||||||
|
|
Loading…
Reference in New Issue