documentation

This commit is contained in:
dr. M.S. (Matthijs) Berends 2022-12-30 13:02:37 +01:00
parent e4ea96cbf9
commit 77d9cf1936
5 changed files with 12 additions and 21 deletions

View File

@ -1,5 +1,5 @@
Package: AMR
Version: 1.8.2.9075
Version: 1.8.2.9076
Date: 2022-12-30
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -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!)*

View File

@ -27,11 +27,11 @@
# 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 ... 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`
#' @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")
}
#' @rdname mean_amr_distance
#' @noRd
#' @export
mean_amr_distance.default <- function(x, ...) {
x <- as.double(x)
(x - mean(x, na.rm = TRUE)) / stats::sd(x, na.rm = TRUE)
}
#' @rdname mean_amr_distance
#' @noRd
#' @export
mean_amr_distance.mic <- function(x, ...) {
mean_amr_distance(log2(x))
}
#' @rdname mean_amr_distance
#' @noRd
#' @export
mean_amr_distance.disk <- function(x, ...) {
mean_amr_distance(as.double(x))

View File

@ -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
\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.}
\item{rescale.p}{a logical scalar; if TRUE then \code{p} is rescaled

View File

@ -2,22 +2,13 @@
% Please edit documentation in R/mean_amr_distance.R
\name{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.data.frame}
\alias{amr_distance_from_row}
\title{Mean AMR Distance}
\title{Calculate the Mean AMR Distance}
\usage{
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}{data.frame}(x, ..., combine_SI = TRUE)
@ -27,7 +18,7 @@ amr_distance_from_row(amr_distance, row)
\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{...}{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}}
@ -36,7 +27,7 @@ amr_distance_from_row(amr_distance, row)
\item{row}{an index, such as a row number}
}
\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{
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).