mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 07:26:13 +01:00
emph guess_bactid
This commit is contained in:
parent
36a5493099
commit
7c667eb732
@ -33,7 +33,6 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- r: 3.1
|
- r: 3.1
|
||||||
- r: 3.2
|
|
||||||
- r: devel
|
- r: devel
|
||||||
r_packages: covr
|
r_packages: covr
|
||||||
cache: packages
|
cache: packages
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -7,7 +7,7 @@
|
|||||||
* Universal: amoxicillin, amoxicillin/clavlanic acid, cefuroxime, piperacillin/tazobactam, ciprofloxacin, trimethoprim/sulfamethoxazole
|
* Universal: amoxicillin, amoxicillin/clavlanic acid, cefuroxime, piperacillin/tazobactam, ciprofloxacin, trimethoprim/sulfamethoxazole
|
||||||
* Gram-positive: vancomycin, teicoplanin, tetracycline, erythromycin, oxacillin, rifampicin
|
* Gram-positive: vancomycin, teicoplanin, tetracycline, erythromycin, oxacillin, rifampicin
|
||||||
* Gram-negative: gentamicin, tobramycin, colistin, cefotaxime, ceftazidime, meropenem
|
* Gram-negative: gentamicin, tobramycin, colistin, cefotaxime, ceftazidime, meropenem
|
||||||
* Functions `as.bactid` and `is.bactid` to transform/look up microbial ID's; this replaces the function `guess_bactid` but it will remain available for backwards compatibility
|
* Functions `as.bactid` and `is.bactid` to transform/look up microbial ID's
|
||||||
* For convience, new descriptive statistical functions `kurtosis` and `skewness` that are lacking in base R - they are generic functions and have support for vectors, data.frames and matrices
|
* For convience, new descriptive statistical functions `kurtosis` and `skewness` that are lacking in base R - they are generic functions and have support for vectors, data.frames and matrices
|
||||||
* Function `g.test` to perform the Χ<sup>2</sup> distributed [*G*-test](https://en.wikipedia.org/wiki/G-test), which use is the same as `chisq.test`
|
* Function `g.test` to perform the Χ<sup>2</sup> distributed [*G*-test](https://en.wikipedia.org/wiki/G-test), which use is the same as `chisq.test`
|
||||||
* Function `ratio` to transform a vector of values to a preset ratio
|
* Function `ratio` to transform a vector of values to a preset ratio
|
||||||
|
26
R/bactid.R
26
R/bactid.R
@ -21,7 +21,9 @@
|
|||||||
#' Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
#' Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
||||||
#' @param x a character vector or a dataframe with one or two columns
|
#' @param x a character vector or a dataframe with one or two columns
|
||||||
#' @rdname as.bactid
|
#' @rdname as.bactid
|
||||||
#' @details Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. For example:
|
#' @details \code{guess_bactid} does exactly the same as \code{as.bactid}.
|
||||||
|
#'
|
||||||
|
#' Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. For example:
|
||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
#' \item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
||||||
#' \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae}}
|
#' \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae}}
|
||||||
@ -53,17 +55,16 @@
|
|||||||
#' library(dplyr)
|
#' library(dplyr)
|
||||||
#' df$bactid <- df %>%
|
#' df$bactid <- df %>%
|
||||||
#' select(microorganism_name) %>%
|
#' select(microorganism_name) %>%
|
||||||
#' as.bactid()
|
#' guess_bactid()
|
||||||
#'
|
#'
|
||||||
#' # and can even contain 2 columns, which is convenient for genus/species combinations:
|
#' # and can even contain 2 columns, which is convenient for genus/species combinations:
|
||||||
#' df$bactid <- df %>%
|
#' df$bactid <- df %>%
|
||||||
#' select(genus, species) %>%
|
#' select(genus, species) %>%
|
||||||
#' as.bactid()
|
#' guess_bactid()
|
||||||
#'
|
#'
|
||||||
#' # same result:
|
#' # same result:
|
||||||
#' df <- df %>%
|
#' df <- df %>%
|
||||||
#' mutate(bactid = paste(genus, species) %>%
|
#' mutate(bactid = guess_bactid(paste(genus, species)))
|
||||||
#' as.bactid())
|
|
||||||
#' }
|
#' }
|
||||||
as.bactid <- function(x) {
|
as.bactid <- function(x) {
|
||||||
|
|
||||||
@ -158,7 +159,8 @@ as.bactid <- function(x) {
|
|||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (toupper(x.backup[i]) == 'MRSE') {
|
if (toupper(x.backup[i]) == 'MRSE') {
|
||||||
x[i] <- 'Staphylococcus epidermidis'
|
x[i] <- 'STAEPI'
|
||||||
|
next
|
||||||
}
|
}
|
||||||
if (toupper(x.backup[i]) == 'VRE') {
|
if (toupper(x.backup[i]) == 'VRE') {
|
||||||
x[i] <- 'ENC'
|
x[i] <- 'ENC'
|
||||||
@ -169,15 +171,9 @@ as.bactid <- function(x) {
|
|||||||
x[i] <- 'PSEAER'
|
x[i] <- 'PSEAER'
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
if (toupper(x.backup[i]) == 'PISP'
|
if (toupper(x.backup[i]) %in% c('PISP', 'PRSP', 'VISP', 'VRSP')) {
|
||||||
| toupper(x.backup[i]) == 'PRSP') {
|
# peni R, peni I, vanco I, vanco R: S. pneumoniae
|
||||||
# peni resistant S. pneumoniae
|
x[i] <- 'STCPNE'
|
||||||
x[i] <- 'Streptococcus pneumoniae'
|
|
||||||
}
|
|
||||||
if (toupper(x.backup[i]) == 'VISP'
|
|
||||||
| toupper(x.backup[i]) == 'VRSP') {
|
|
||||||
# vanco resistant S. pneumoniae
|
|
||||||
x[i] <- 'Streptococcus pneumoniae'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ The functions to calculate microbial resistance use expressions that are not eva
|
|||||||
This package [is published on CRAN](http://cran.r-project.org/package=AMR), the official R network.
|
This package [is published on CRAN](http://cran.r-project.org/package=AMR), the official R network.
|
||||||
|
|
||||||
### Install from CRAN (recommended)
|
### Install from CRAN (recommended)
|
||||||
[![CRAN_Badge](https://img.shields.io/cran/v/AMR.svg?label=CRAN)](http://cran.r-project.org/package=AMR) [![CRAN_Downloads](https://cranlogs.r-pkg.org/badges/grand-total/AMR)](http://cran.r-project.org/package=AMR)
|
[![CRAN_Badge](https://img.shields.io/cran/v/AMR.svg?label=CRAN&colorB=3679BC)](http://cran.r-project.org/package=AMR) [![CRAN_Downloads](https://cranlogs.r-pkg.org/badges/grand-total/AMR)](http://cran.r-project.org/package=AMR)
|
||||||
|
|
||||||
(Note: downloads measured only by [cran.rstudio.com](https://cran.rstudio.com/package=AMR), i.e. this excludes the official [cran.r-project.org](https://cran.r-project.org/package=AMR))
|
(Note: Downloads measured only by [cran.rstudio.com](https://cran.rstudio.com/package=AMR), this excludes e.g. the official [cran.r-project.org](https://cran.r-project.org/package=AMR))
|
||||||
|
|
||||||
- <img src="http://www.rstudio.com/favicon.ico" alt="RStudio favicon" height="20px"> Install using [RStudio](http://www.rstudio.com) (recommended):
|
- <img src="http://www.rstudio.com/favicon.ico" alt="RStudio favicon" height="20px"> Install using [RStudio](http://www.rstudio.com) (recommended):
|
||||||
- Click on `Tools` and then `Install Packages...`
|
- Click on `Tools` and then `Install Packages...`
|
||||||
|
@ -22,6 +22,8 @@ Character (vector) with class \code{"bactid"}. Unknown values will return \code{
|
|||||||
Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
||||||
}
|
}
|
||||||
\details{
|
\details{
|
||||||
|
\code{guess_bactid} does exactly the same as \code{as.bactid}.
|
||||||
|
|
||||||
Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. For example:
|
Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. For example:
|
||||||
\itemize{
|
\itemize{
|
||||||
\item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
\item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
|
||||||
@ -51,17 +53,16 @@ df$bactid <- as.bactid(df$microorganism_name)
|
|||||||
library(dplyr)
|
library(dplyr)
|
||||||
df$bactid <- df \%>\%
|
df$bactid <- df \%>\%
|
||||||
select(microorganism_name) \%>\%
|
select(microorganism_name) \%>\%
|
||||||
as.bactid()
|
guess_bactid()
|
||||||
|
|
||||||
# and can even contain 2 columns, which is convenient for genus/species combinations:
|
# and can even contain 2 columns, which is convenient for genus/species combinations:
|
||||||
df$bactid <- df \%>\%
|
df$bactid <- df \%>\%
|
||||||
select(genus, species) \%>\%
|
select(genus, species) \%>\%
|
||||||
as.bactid()
|
guess_bactid()
|
||||||
|
|
||||||
# same result:
|
# same result:
|
||||||
df <- df \%>\%
|
df <- df \%>\%
|
||||||
mutate(bactid = paste(genus, species) \%>\%
|
mutate(bactid = guess_bactid(paste(genus, species)))
|
||||||
as.bactid())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
|
Loading…
Reference in New Issue
Block a user