mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 06:06:12 +01:00
mean AMR distance
This commit is contained in:
parent
178ab5e5ff
commit
faca6d608a
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 1.8.2.9028
|
||||
Version: 1.8.2.9029
|
||||
Date: 2022-10-21
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
@ -189,6 +189,7 @@ export(age_groups)
|
||||
export(all_antimicrobials)
|
||||
export(aminoglycosides)
|
||||
export(aminopenicillins)
|
||||
export(amr_distance_from_row)
|
||||
export(anti_join_microorganisms)
|
||||
export(antifungals)
|
||||
export(antimicrobials_equal)
|
||||
@ -265,7 +266,6 @@ export(mdr_cmi2012)
|
||||
export(mdr_tb)
|
||||
export(mdro)
|
||||
export(mean_amr_distance)
|
||||
export(mean_distance_from_row)
|
||||
export(mo_authors)
|
||||
export(mo_class)
|
||||
export(mo_cleaning_regex)
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 1.8.2.9028
|
||||
# AMR 1.8.2.9029
|
||||
|
||||
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
#'
|
||||
#' For data sets, the mean AMR distance will be calculated per variable, after which the mean of all columns will returned per row (using [rowMeans()]), see *Examples*.
|
||||
#'
|
||||
#' Use [mean_distance_from_row()] to subtract distances from the distance of one row, see *Examples*.
|
||||
#' Use [amr_distance_from_row()] to subtract distances from the distance of one row, see *Examples*.
|
||||
#' @section Interpretation:
|
||||
#' Isolates with distances less than 0.01 difference from each other should be considered similar. Differences lower than 0.025 should be considered suspicious.
|
||||
#' @export
|
||||
@ -66,7 +66,7 @@
|
||||
#' y %>%
|
||||
#' mutate(
|
||||
#' amr_distance = mean_amr_distance(., where(is.mic)),
|
||||
#' check_id_C = mean_distance_from_row(amr_distance, id == "C")
|
||||
#' check_id_C = amr_distance_from_row(amr_distance, id == "C")
|
||||
#' ) %>%
|
||||
#' arrange(check_id_C)
|
||||
#' }
|
||||
@ -154,14 +154,14 @@ mean_amr_distance.data.frame <- function(x, ..., combine_SI = TRUE) {
|
||||
}
|
||||
|
||||
#' @rdname mean_amr_distance
|
||||
#' @param mean_distance the outcome of [mean_amr_distance()]
|
||||
#' @param amr_distance the outcome of [mean_amr_distance()]
|
||||
#' @param row an index, such as a row number
|
||||
#' @export
|
||||
mean_distance_from_row <- function(mean_distance, row) {
|
||||
meet_criteria(mean_distance, allow_class = c("double", "numeric"), is_finite = TRUE)
|
||||
amr_distance_from_row <- function(amr_distance, row) {
|
||||
meet_criteria(amr_distance, allow_class = c("double", "numeric"), is_finite = TRUE)
|
||||
meet_criteria(row, allow_class = c("logical", "double", "numeric"))
|
||||
if (is.logical(row)) {
|
||||
row <- which(row)
|
||||
}
|
||||
abs(mean_distance[row] - mean_distance)
|
||||
abs(amr_distance[row] - amr_distance)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
\alias{mean_amr_distance.disk}
|
||||
\alias{mean_amr_distance.rsi}
|
||||
\alias{mean_amr_distance.data.frame}
|
||||
\alias{mean_distance_from_row}
|
||||
\alias{amr_distance_from_row}
|
||||
\title{Mean AMR Distance}
|
||||
\usage{
|
||||
mean_amr_distance(x, ...)
|
||||
@ -22,7 +22,7 @@ mean_amr_distance(x, ...)
|
||||
|
||||
\method{mean_amr_distance}{data.frame}(x, ..., combine_SI = TRUE)
|
||||
|
||||
mean_distance_from_row(mean_distance, row)
|
||||
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}
|
||||
@ -31,7 +31,7 @@ mean_distance_from_row(mean_distance, row)
|
||||
|
||||
\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{mean_distance}{the outcome of \code{\link[=mean_amr_distance]{mean_amr_distance()}}}
|
||||
\item{amr_distance}{the outcome of \code{\link[=mean_amr_distance]{mean_amr_distance()}}}
|
||||
|
||||
\item{row}{an index, such as a row number}
|
||||
}
|
||||
@ -47,7 +47,7 @@ R/SI values (see \code{\link[=as.rsi]{as.rsi()}}) are transformed using \code{"S
|
||||
|
||||
For data sets, the mean AMR distance will be calculated per variable, after which the mean of all columns will returned per row (using \code{\link[=rowMeans]{rowMeans()}}), see \emph{Examples}.
|
||||
|
||||
Use \code{\link[=mean_distance_from_row]{mean_distance_from_row()}} to subtract distances from the distance of one row, see \emph{Examples}.
|
||||
Use \code{\link[=amr_distance_from_row]{amr_distance_from_row()}} to subtract distances from the distance of one row, see \emph{Examples}.
|
||||
}
|
||||
\section{Interpretation}{
|
||||
|
||||
@ -75,7 +75,7 @@ if (require("dplyr")) {
|
||||
y \%>\%
|
||||
mutate(
|
||||
amr_distance = mean_amr_distance(., where(is.mic)),
|
||||
check_id_C = mean_distance_from_row(amr_distance, id == "C")
|
||||
check_id_C = amr_distance_from_row(amr_distance, id == "C")
|
||||
) \%>\%
|
||||
arrange(check_id_C)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user