1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 16:42:10 +02:00

massive update for antivirals

This commit is contained in:
2022-11-12 21:34:24 +01:00
parent d2edcf51ad
commit 8fab745ab1
35 changed files with 1728 additions and 169 deletions

View File

@ -32,7 +32,7 @@ Welcome to the \code{AMR} package.
This work was published in the Journal of Statistical Software (Volume 104(3); \doi{10.18637/jss.v104.i03}) and formed the basis of two PhD theses (\doi{10.33612/diss.177417131} and \doi{10.33612/diss.192486375}).
After installing this package, \R knows ~49,000 distinct microbial species and all ~580 antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-NET, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.
After installing this package, \R knows ~49,000 distinct microbial species and all ~600 antibiotic, antimycotic and antiviral drugs by name and code (including ATC, EARS-NET, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.
This package is fully independent of any other \R package and works on Windows, macOS and Linux with all versions of \R since R-3.0.0 (April 2013). It was designed to work in any setting, including those with very limited resources. It was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the University of Groningen, in collaboration with non-profit organisations Certe Medical Diagnostics and Advice and University Medical Center Groningen. This \R package is actively maintained and free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation.

View File

@ -60,7 +60,7 @@ With using \code{collapse}, this function will return a \link{character}:\cr
\examples{
# mind the bad spelling of amoxicillin in this line,
# straight from a true health care record:
ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds")
ab_from_text("28/03/2020 regular amoxicilliin 500mg po tid")
ab_from_text("500 mg amoxi po and 400mg cipro iv")
ab_from_text("500 mg amoxi po and 400mg cipro iv", type = "dose")

View File

@ -4,7 +4,7 @@
\name{antibiotics}
\alias{antibiotics}
\alias{antivirals}
\title{Data Sets with 585 Antimicrobial Drugs}
\title{Data Sets with 603 Antimicrobial Drugs}
\format{
\subsection{For the \link{antibiotics} data set: a \link[tibble:tibble]{tibble} with 483 observations and 14 variables:}{
\itemize{
@ -25,21 +25,23 @@
}
}
\subsection{For the \link{antivirals} data set: a \link[tibble:tibble]{tibble} with 102 observations and 9 variables:}{
\subsection{For the \link{antivirals} data set: a \link[tibble:tibble]{tibble} with 120 observations and 11 variables:}{
\itemize{
\item \code{av}\cr Antibiotic ID as used in this package (such as \code{AMC}), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
\item \code{name}\cr Official name as used by WHONET/EARS-Net or the WHO
\item \code{atc}\cr ATC codes (Anatomical Therapeutic Chemical) as defined by the WHOCC
\item \code{cid}\cr Compound ID as found in PubChem
\item \code{name}\cr Official name as used by WHONET/EARS-Net or the WHO
\item \code{atc_group}\cr Official pharmacological subgroup (3rd level ATC code) as defined by the WHOCC
\item \code{synonyms}\cr Synonyms (often trade names) of a drug, as found in PubChem based on their compound ID
\item \code{oral_ddd}\cr Defined Daily Dose (DDD), oral treatment
\item \code{oral_units}\cr Units of \code{oral_ddd}
\item \code{iv_ddd}\cr Defined Daily Dose (DDD), parenteral treatment
\item \code{iv_units}\cr Units of \code{iv_ddd}
\item \code{loinc}\cr All LOINC codes (Logical Observation Identifiers Names and Codes) associated with the name of the antimicrobial agent.
}
}
An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 102 rows and 9 columns.
An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 120 rows and 11 columns.
}
\source{
\itemize{

View File

@ -87,8 +87,8 @@ ab_atc("seephthriaaksone") # and even this works
# use ab_* functions to get a specific properties (see ?ab_property);
# they use as.ab() internally:
ab_name("J01FA01") # "Erythromycin"
ab_name("eryt") # "Erythromycin"
ab_name("J01FA01")
ab_name("eryt")
\donttest{
if (require("dplyr")) {

91
man/as.av.Rd Normal file
View File

@ -0,0 +1,91 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/av.R
\name{as.av}
\alias{as.av}
\alias{ab}
\alias{is.av}
\title{Transform Input to an Antiviral Agent ID}
\usage{
as.av(x, flag_multiple_results = TRUE, info = interactive(), ...)
is.av(x)
}
\arguments{
\item{x}{a \link{character} vector to determine to antiviral agent ID}
\item{flag_multiple_results}{a \link{logical} to indicate whether a note should be printed to the console that probably more than one antiviral agent code or name can be retrieved from a single input value.}
\item{info}{a \link{logical} to indicate whether a progress bar should be printed, defaults to \code{TRUE} only in interactive mode}
\item{...}{arguments passed on to internal functions}
}
\value{
A \link{character} \link{vector} with additional class \code{\link{ab}}
}
\description{
Use this function to determine the antiviral agent code of one or more antiviral agents. The data set \link{antivirals} will be searched for abbreviations, official names and synonyms (brand names).
}
\details{
All entries in the \link{antivirals} data set have three different identifiers: a human readable EARS-Net code (column \code{ab}, used by ECDC and WHONET), an ATC code (column \code{atc}, used by WHO), and a CID code (column \code{cid}, Compound ID, used by PubChem). The data set contains more than 5,000 official brand names from many different countries, as found in PubChem. Not that some drugs contain multiple ATC codes.
All these properties will be searched for the user input. The \code{\link[=as.av]{as.av()}} can correct for different forms of misspelling:
\itemize{
\item Wrong spelling of drug names (such as "acyclovir"), which corrects for most audible similarities such as f/ph, x/ks, c/z/s, t/th, etc.
\item Too few or too many vowels or consonants
\item Switching two characters (such as "aycclovir", often the case in clinical data, when doctors typed too fast)
\item Digitalised paper records, leaving artefacts like 0/o/O (zero and O's), B/8, n/r, etc.
}
Use the \code{\link[=av_property]{av_*}} functions to get properties based on the returned antiviral agent ID, see \emph{Examples}.
Note: the \code{\link[=as.av]{as.av()}} and \code{\link[=av_property]{av_*}} functions may use very long regular expression to match brand names of antimicrobial agents. This may fail on some systems.
}
\section{Source}{
World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/}
European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}
}
\section{WHOCC}{
\if{html}{\figure{logo_who.png}{options: height="60" style=margin-bottom:"5"} \cr}
This package contains \strong{all ~550 antibiotic, antimycotic and antiviral drugs} and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, \url{https://www.whocc.no}) and the Pharmaceuticals Community Register of the European Commission (\url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}).
These have become the gold standard for international drug utilisation monitoring and research.
The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest.
\strong{NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package.} See \url{https://www.whocc.no/copyright_disclaimer/.}
}
\section{Reference Data Publicly Available}{
All data sets in this \code{AMR} package (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. We also provide tab-separated plain text files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please visit \href{https://msberends.github.io/AMR/articles/datasets.html}{our website for the download links}. The actual files are of course available on \href{https://github.com/msberends/AMR/tree/main/data-raw}{our GitHub repository}.
}
\examples{
# these examples all return "ACI", the ID of aciclovir:
as.av("J05AB01")
as.av("J 05 AB 01")
as.av("Aciclovir")
as.av("aciclo")
as.av(" aciclo 123")
as.av("ACICL")
as.av("ACI")
as.av("Virorax") # trade name
as.av("Zovirax") # trade name
as.av("acyklofir") # severe spelling error, yet works
# use av_* functions to get a specific properties (see ?av_property);
# they use as.av() internally:
av_name("J05AB01")
av_name("acicl")
}
\seealso{
\itemize{
\item \link{antivirals} for the \link{data.frame} that is being used to determine ATCs
\item \code{\link[=av_from_text]{av_from_text()}} for a function to retrieve antimicrobial drugs from clinical text (from health care records)
}
}

63
man/av_from_text.Rd Normal file
View File

@ -0,0 +1,63 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/av_from_text.R
\name{av_from_text}
\alias{av_from_text}
\title{Retrieve Antiviral Drug Names and Doses from Clinical Text}
\usage{
av_from_text(
text,
type = c("drug", "dose", "administration"),
collapse = NULL,
translate_av = FALSE,
thorough_search = NULL,
info = interactive(),
...
)
}
\arguments{
\item{text}{text to analyse}
\item{type}{type of property to search for, either \code{"drug"}, \code{"dose"} or \code{"administration"}, see \emph{Examples}}
\item{collapse}{a \link{character} to pass on to \code{paste(, collapse = ...)} to only return one \link{character} per element of \code{text}, see \emph{Examples}}
\item{translate_av}{if \code{type = "drug"}: a column name of the \link{antivirals} data set to translate the antibiotic abbreviations to, using \code{\link[=av_property]{av_property()}}. Defaults to \code{FALSE}. Using \code{TRUE} is equal to using "name".}
\item{thorough_search}{a \link{logical} to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to \code{TRUE} will take considerably more time than when using \code{FALSE}. At default, it will turn \code{TRUE} when all input elements contain a maximum of three words.}
\item{info}{a \link{logical} to indicate whether a progress bar should be printed, defaults to \code{TRUE} only in interactive mode}
\item{...}{arguments passed on to \code{\link[=as.av]{as.av()}}}
}
\value{
A \link{list}, or a \link{character} if \code{collapse} is not \code{NULL}
}
\description{
Use this function on e.g. clinical texts from health care records. It returns a \link{list} with all antiviral drugs, doses and forms of administration found in the texts.
}
\details{
This function is also internally used by \code{\link[=as.av]{as.av()}}, although it then only searches for the first drug name and will throw a note if more drug names could have been returned. Note: the \code{\link[=as.av]{as.av()}} function may use very long regular expression to match brand names of antiviral agents. This may fail on some systems.
\subsection{Argument \code{type}}{
At default, the function will search for antiviral drug names. All text elements will be searched for official names, ATC codes and brand names. As it uses \code{\link[=as.av]{as.av()}} internally, it will correct for misspelling.
With \code{type = "dose"} (or similar, like "dosing", "doses"), all text elements will be searched for \link{numeric} values that are higher than 100 and do not resemble years. The output will be \link{numeric}. It supports any unit (g, mg, IE, etc.) and multiple values in one clinical text, see \emph{Examples}.
With \code{type = "administration"} (or abbreviations, like "admin", "adm"), all text elements will be searched for a form of drug administration. It supports the following forms (including common abbreviations): buccal, implant, inhalation, instillation, intravenous, nasal, oral, parenteral, rectal, sublingual, transdermal and vaginal. Abbreviations for oral (such as 'po', 'per os') will become "oral", all values for intravenous (such as 'iv', 'intraven') will become "iv". It supports multiple values in one clinical text, see \emph{Examples}.
}
\subsection{Argument \code{collapse}}{
Without using \code{collapse}, this function will return a \link{list}. This can be convenient to use e.g. inside a \code{mutate()}):\cr
\code{df \%>\% mutate(avx = av_from_text(clinical_text))}
The returned AV codes can be transformed to official names, groups, etc. with all \code{\link[=av_property]{av_*}} functions such as \code{\link[=av_name]{av_name()}} and \code{\link[=av_group]{av_group()}}, or by using the \code{translate_av} argument.
With using \code{collapse}, this function will return a \link{character}:\cr
\code{df \%>\% mutate(avx = av_from_text(clinical_text, collapse = "|"))}
}
}
\examples{
av_from_text("28/03/2020 valaciclovir po tid")
av_from_text("28/03/2020 valaciclovir po tid", type = "admin")
}

129
man/av_property.Rd Normal file
View File

@ -0,0 +1,129 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/av_property.R
\name{av_property}
\alias{av_property}
\alias{av_name}
\alias{av_cid}
\alias{av_synonyms}
\alias{av_tradenames}
\alias{av_group}
\alias{av_atc}
\alias{ATC}
\alias{av_loinc}
\alias{av_ddd}
\alias{av_ddd_units}
\alias{av_info}
\alias{av_url}
\title{Get Properties of an Antiviral Agent}
\usage{
av_name(x, language = get_AMR_locale(), tolower = FALSE, ...)
av_cid(x, ...)
av_synonyms(x, ...)
av_tradenames(x, ...)
av_group(x, language = get_AMR_locale(), ...)
av_atc(x, only_first = FALSE, ...)
av_loinc(x, ...)
av_ddd(x, administration = "oral", ...)
av_ddd_units(x, administration = "oral", ...)
av_info(x, language = get_AMR_locale(), ...)
av_url(x, open = FALSE, ...)
av_property(x, property = "name", language = get_AMR_locale(), ...)
}
\arguments{
\item{x}{any (vector of) text that can be coerced to a valid antiviral agent code with \code{\link[=as.av]{as.av()}}}
\item{language}{language of the returned text, defaults to system language (see \code{\link[=get_AMR_locale]{get_AMR_locale()}}) and can also be set with \code{getOption("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation.}
\item{tolower}{a \link{logical} to indicate whether the first \link{character} of every output should be transformed to a lower case \link{character}.}
\item{...}{other arguments passed on to \code{\link[=as.av]{as.av()}}}
\item{administration}{way of administration, either \code{"oral"} or \code{"iv"}}
\item{open}{browse the URL using \code{\link[utils:browseURL]{utils::browseURL()}}}
\item{property}{one of the column names of one of the \link{antivirals} data set: \code{vector_or(colnames(antivirals), sort = FALSE)}.}
}
\value{
\itemize{
\item An \link{integer} in case of \code{\link[=av_cid]{av_cid()}}
\item A named \link{list} in case of \code{\link[=av_info]{av_info()}} and multiple \code{\link[=av_atc]{av_atc()}}/\code{\link[=av_synonyms]{av_synonyms()}}/\code{\link[=av_tradenames]{av_tradenames()}}
\item A \link{double} in case of \code{\link[=av_ddd]{av_ddd()}}
\item A \link{character} in all other cases
}
}
\description{
Use these functions to return a specific property of an antiviral agent from the \link{antivirals} data set. All input values will be evaluated internally with \code{\link[=as.av]{as.av()}}.
}
\details{
All output \link[=translate]{will be translated} where possible.
The function \code{\link[=av_url]{av_url()}} will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available.
}
\section{Source}{
World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/}
European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm}
}
\section{Reference Data Publicly Available}{
All data sets in this \code{AMR} package (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. We also provide tab-separated plain text files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please visit \href{https://msberends.github.io/AMR/articles/datasets.html}{our website for the download links}. The actual files are of course available on \href{https://github.com/msberends/AMR/tree/main/data-raw}{our GitHub repository}.
}
\examples{
# all properties:
av_name("AMX") # "Amoxicillin"
av_atc("AMX") # "J01CA04" (ATC code from the WHO)
av_cid("AMX") # 33613 (Compound ID from PubChem)
av_synonyms("AMX") # a list with brand names of amoxicillin
av_tradenames("AMX") # same
av_group("AMX") # "Beta-lactams/penicillins"
av_atc_group1("AMX") # "Beta-lactam antibacterials, penicillins"
av_atc_group2("AMX") # "Penicillins with extended spectrum"
av_url("AMX") # link to the official WHO page
# smart lowercase tranformation
av_name(x = c("AMC", "PLB")) # "Amoxicillin/clavulanic acid" "Polymyxin B"
av_name(
x = c("AMC", "PLB"),
tolower = TRUE
) # "amoxicillin/clavulanic acid" "polymyxin B"
# defined daily doses (DDD)
av_ddd("AMX", "oral") # 1.5
av_ddd_units("AMX", "oral") # "g"
av_ddd("AMX", "iv") # 3
av_ddd_units("AMX", "iv") # "g"
av_info("AMX") # all properties as a list
# all av_* functions use as.av() internally, so you can go from 'any' to 'any':
av_atc("AMP") # ATC code of AMP (ampicillin)
av_group("J01CA01") # Drug group of ampicillins ATC code
av_loinc("ampicillin") # LOINC codes of ampicillin
av_name("21066-6") # "Ampicillin" (using LOINC)
av_name(6249) # "Ampicillin" (using CID)
av_name("J01CA01") # "Ampicillin" (using ATC)
# spelling from different languages and dyslexia are no problem
av_atc("ceftriaxon")
av_atc("cephtriaxone")
av_atc("cephthriaxone")
av_atc("seephthriaaksone")
}
\seealso{
\link{antivirals}
}