diff --git a/docs/articles/index.html b/docs/articles/index.html index c3f4deeb..4c7e428d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -163,7 +163,6 @@
diff --git a/docs/extra.css b/docs/extra.css index b59420c8..5c0cf18c 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -1,3 +1,11 @@ +/* class for footer */ +.university { + background-image: url(logo_rug.png); + height: 40px; + background-size: 160px; + background-repeat: no-repeat; +} + /* Supports icons for brand using font-awesome */ .fab { font-family: "Font Awesome 5 Brands" !important; diff --git a/docs/extra.js b/docs/extra.js index 14071dbf..fce10395 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -1,3 +1,11 @@ // Add updated Font Awesome 5.6.3 library $('head').append(''); -$('footer p').text($('footer p').text().replace('Developed by', 'Authors:')); + +/* edit footer */ +$( document ).ready(function() { + $('footer').html('' +
+ $('footer .copyright p').html().replace("Developed by",
+ "AMR
(for R). Developed at the University of Groningen.
Authors:") +
+ '
AMR
is a free and open-source R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with antibiotic properties by using evidence-based methods.
We created this package for academic research at the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). We released this under the GNU General Public Licence v2.0 (GPL-2) which makes it free for everybody to use and distribute, for personal and commercial use, but it may not be used for patent purposes. Read further about our GPL-2 licence here.
This package is ready-to-use for a professional environment by specialists in the following fields:
-Medical Microbiology:
Veterinary Microbiology:
Microbial Ecology:
Other specialists in any of the above fields:
Developers:
age
to calculate the (patients) age in yearsage_groups
to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.Functions filter_first_isolate
and filter_first_weighted_isolate()
to shorten and fasten filtering on data sets with antimicrobial results, e.g.:
septic_patients %>% filter_first_isolate()
+Functions filter_first_isolate
and filter_first_weighted_isolate()
to shorten and fasten filtering on data sets with antimicrobial results, e.g.:
+
+filter_first_isolate(septic_patients)
is equal to:
mdro
, key_antibiotics
and eucast_rules
resistance_predict
function)as.mic
to support more values ending in (several) zeroesas.mo
will return NAFunction as.mo
(and all mo_*
wrappers) now supports genus abbreviations with “species” attached
combine_IR
(TRUE/FALSE) to functions portion_df
and count_df
, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)portion_*(..., as_percent = TRUE)
when minimal number of isolates would not be metalso_single_tested
for portion_*
and count_*
functions to also include cases where not all antibiotics were tested but at least one of the tested antibiotics includes the target antimicribial interpretation, see ?portion
+also_single_tested
for portion_*
and count_*
functions to also include cases where not all antibiotics were tested but at least one of the tested antibiotics includes the target antimicribial interpretation, see ?portion
portion_*
functions now throws a warning when total available isolate is below parameter minimum
as.mo
, as.rsi
, as.mic
, as.atc
and freq
will not set package name as attribute anymorefreq()
:
+freq()
:
Support for grouping variables, test with:
+ freq(gender)Support for (un)selecting columns:
hms::is.hms
@@ -340,7 +341,7 @@
microorganisms$ref
and microorganisms.old$ref
) to comply with CRAN policy to only allow ASCII charactersmo_property
not working properlyeucast_rules
where some Streptococci would become ceftazidime R in EUCAST rule 4.5mo
, useful for top_freq()
+mo
, useful for top_freq()
ggplot_rsi
and scale_y_percent
have breaks
parameterThey also come with support for German, Dutch, French, Italian, Spanish and Portuguese:
-mo_gramstain("E. coli")
+mo_gramstain("E. coli")
# [1] "Gram negative"
-mo_gramstain("E. coli", language = "de") # German
+mo_gramstain("E. coli", language = "de") # German
# [1] "Gramnegativ"
-mo_gramstain("E. coli", language = "es") # Spanish
+mo_gramstain("E. coli", language = "es") # Spanish
# [1] "Gram negativo"
-mo_fullname("S. group A", language = "pt") # Portuguese
+mo_fullname("S. group A", language = "pt") # Portuguese
# [1] "Streptococcus grupo A"
Furthermore, former taxonomic names will give a note about the current taxonomic name:
-mo_gramstain("Esc blattae")
+mo_gramstain("Esc blattae")
# Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)
# [1] "Gram negative"
@@ -422,15 +423,15 @@
Functions as.mo
and is.mo
as replacements for as.bactid
and is.bactid
(since the microoganisms
data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo
function determines microbial IDs using Artificial Intelligence (AI):
-as.mo("E. coli")
+as.mo("E. coli")
# [1] B_ESCHR_COL
-as.mo("MRSA")
+as.mo("MRSA")
# [1] B_STPHY_AUR
-as.mo("S group A")
+as.mo("S group A")
# [1] B_STRPTC_GRA
And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:
thousands_of_E_colis <- rep("E. coli", 25000)
-microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
+microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
# Unit: seconds
# min median max neval
# 0.01817717 0.01843957 0.03878077 100
@@ -461,11 +462,11 @@
Added three antimicrobial agents to the antibiotics
data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)
Added 163 trade names to the antibiotics
data set, it now contains 298 different trade names in total, e.g.:
-ab_official("Bactroban")
+ab_official("Bactroban")
# [1] "Mupirocin"
-ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
+ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
# [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"
-ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
+ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
For first_isolate
, rows will be ignored when there’s no species available
@@ -477,13 +478,13 @@
Support for quasiquotation in the functions series count_*
and portions_*
, and n_rsi
. This allows to check for more than 2 vectors or columns.
-septic_patients %>% select(amox, cipr) %>% count_IR()
+septic_patients %>% select(amox, cipr) %>% count_IR()
# which is the same as:
-septic_patients %>% count_IR(amox, cipr)
+septic_patients %>% count_IR(amox, cipr)
-septic_patients %>% portion_S(amcl)
-septic_patients %>% portion_S(amcl, gent)
-septic_patients %>% portion_S(amcl, gent, pita)
+septic_patients %>% portion_S(amcl)
+septic_patients %>% portion_S(amcl, gent)
+septic_patients %>% portion_S(amcl, gent, pita)
Edited ggplot_rsi
and geom_rsi
so they can cope with count_df
. The new fun
parameter has value portion_df
at default, but can be set to count_df
.
Fix for ggplot_rsi
when the ggplot2
package was not loaded
@@ -498,11 +499,11 @@
Support for types (classes) list and matrix for freq
+freq(my_matrix)
For lists, subsetting is possible:
my_list = list(age = septic_patients$age, gender = septic_patients$gender)
-my_list %>% freq(age)
-my_list %>% freq(gender)
+my_list %>% freq(age)
+my_list %>% freq(gender)
@@ -544,7 +545,7 @@
-
septic_patients %>% select(tobr, gent) %>% ggplot_rsi
will show portions of S, I and R immediately in a pretty plot
-- Support for grouped variables, see
?ggplot_rsi
+ - Support for grouped variables, see
?ggplot_rsi
@@ -565,7 +566,7 @@
Function ratio
to transform a vector of values to a preset ratio
-For example: ratio(c(10, 500, 10), ratio = "1:2:1")
would return 130, 260, 130
+For example: ratio(c(10, 500, 10), ratio = "1:2:1")
would return 130, 260, 130
Support for Addins menu in RStudio to quickly insert %in%
or %like%
(and give them keyboard shortcuts), or to view the datasets that come with this package
@@ -576,13 +577,13 @@
- A vignette to explain its usage
- Support for
rsi
(antimicrobial resistance) to use as input
-- Support for
table
to use as input: freq(table(x, y))
+ - Support for
table
to use as input: freq(table(x, y))
- Support for existing functions
hist
and plot
to use a frequency table as input: hist(freq(df$age))
- Support for
as.vector
, as.data.frame
, as_tibble
and format
-- Support for quasiquotation:
freq(mydata, mycolumn)
is the same as mydata %>% freq(mycolumn)
+ - Support for quasiquotation:
freq(mydata, mycolumn)
is the same as mydata %>% freq(mycolumn)
- Function
top_freq
function to return the top/below n items as vector
- Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)
@@ -614,16 +615,16 @@
- Combined MIC/RSI values will now be coerced by the
rsi
and mic
functions:
-
-
as.rsi("<=0.002; S")
will return S
+as.rsi("<=0.002; S")
will return S
-
-
as.mic("<=0.002; S")
will return <=0.002
+as.mic("<=0.002; S")
will return <=0.002
-- Now possible to coerce MIC values with a space between operator and value, i.e.
as.mic("<= 0.002")
now works
+- Now possible to coerce MIC values with a space between operator and value, i.e.
as.mic("<= 0.002")
now works
- Classes
rsi
and mic
do not add the attribute package.version
anymore
-- Added
"groups"
option for atc_property(..., property)
. It will return a vector of the ATC hierarchy as defined by the WHO. The new function atc_groups
is a convenient wrapper around this.
+- Added
"groups"
option for atc_property(..., property)
. It will return a vector of the ATC hierarchy as defined by the WHO. The new function atc_groups
is a convenient wrapper around this.
- Build-in host check for
atc_property
as it requires the host set by url
to be responsive
- Improved
first_isolate
algorithm to exclude isolates where bacteria ID or genus is unavailable
- Fix for warning hybrid evaluation forced for row_number (
924b62
) from the dplyr
package v0.7.5 and above
@@ -661,7 +662,7 @@
- Full support for Windows, Linux and macOS
- Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies)
-- Function
n_rsi
to count cases where antibiotic test results were available, to be used in conjunction with dplyr::summarise
, see ?rsi
+- Function
n_rsi
to count cases where antibiotic test results were available, to be used in conjunction with dplyr::summarise
, see ?rsi
- Function
guess_bactid
to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA
- Function
guess_atc
to determine the ATC of an antibiotic based on name, trade name, or known abbreviations
- Function
freq
to create frequency tables, with additional info in a header
@@ -674,7 +675,7 @@
- Functions
BRMO
and MRGN
are wrappers for Dutch and German guidelines, respectively
-- New algorithm to determine weighted isolates, can now be
"points"
or "keyantibiotics"
, see ?first_isolate
+ - New algorithm to determine weighted isolates, can now be
"points"
or "keyantibiotics"
, see ?first_isolate
- New print format for
tibble
s and data.table
s
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 548eb3e7..7d0e471f 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -1,9 +1,7 @@
pandoc: 2.3.1
pkgdown: 1.3.0
pkgdown_sha: ~
-articles:
- AMR: AMR.html
- freq: freq.html
+articles: []
urls:
reference: https://msberends.gitlab.io/reference
article: https://msberends.gitlab.io/articles
diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html
index c19b6499..97b9e9e7 100644
--- a/docs/reference/ab_property.html
+++ b/docs/reference/ab_property.html
@@ -163,7 +163,7 @@
- Use these functions to return a specific property of an antibiotic from the antibiotics
data set, based on their ATC code. Get such a code with as.atc
.
+ Use these functions to return a specific property of an antibiotic from the antibiotics
data set, based on their ATC code. Get such a code with as.atc
.
@@ -188,11 +188,11 @@
x
- a (vector of a) valid atc
code or any text that can be coerced to a valid atc with as.atc
+ a (vector of a) valid atc
code or any text that can be coerced to a valid atc with as.atc
property
- one of the column names of one of the antibiotics
data set, like "atc"
and "official"
+ one of the column names of one of the antibiotics
data set, like "atc"
and "official"
language
@@ -206,7 +206,7 @@
See also
-
+ antibiotics
Examples
diff --git a/docs/reference/abname.html b/docs/reference/abname.html
index c364a262..d77f8b64 100644
--- a/docs/reference/abname.html
+++ b/docs/reference/abname.html
@@ -163,7 +163,7 @@
- Convert antibiotic codes to a (trivial) antibiotic name or ATC code, or vice versa. This uses the data from antibiotics
.
+ Convert antibiotic codes to a (trivial) antibiotic name or ATC code, or vice versa. This uses the data from antibiotics
.
@@ -179,7 +179,7 @@
from, to
- type to transform from and to. See antibiotics
for its column names. WIth from = "guess"
the from will be guessed from "atc"
, "certe"
and "umcg"
. When using to = "atc"
, the ATC code will be searched using as.atc
.
+ type to transform from and to. See antibiotics
for its column names. WIth from = "guess"
the from will be guessed from "atc"
, "certe"
and "umcg"
. When using to = "atc"
, the ATC code will be searched using as.atc
.
textbetween
@@ -193,11 +193,11 @@
Source
-
+ antibiotics
Details
- The ab_property
functions are faster and more concise, but do not support concatenated strings, like abname("AMCL+GENT"
.
+ The ab_property
functions are faster and more concise, but do not support concatenated strings, like abname("AMCL+GENT"
.
Examples
diff --git a/docs/reference/age.html b/docs/reference/age.html
index 8c5ec6d7..eb34b42a 100644
--- a/docs/reference/age.html
+++ b/docs/reference/age.html
@@ -188,7 +188,7 @@
See also
- age_groups
to splits age into groups
+ age_groups
to splits age into groups
diff --git a/docs/reference/age_groups.html b/docs/reference/age_groups.html
index aaee4aaf..3cfcdd2d 100644
--- a/docs/reference/age_groups.html
+++ b/docs/reference/age_groups.html
@@ -174,7 +174,7 @@
x
- age, e.g. calculated with age
+ age, e.g. calculated with age
split_at
@@ -201,7 +201,7 @@
See also
- age
to determine ages based on one or more reference dates
+ age
to determine ages based on one or more reference dates
Examples
@@ -230,13 +230,13 @@
# resistance of ciprofloxacine per age group
library(dplyr)
septic_patients %>%
- mutate(first_isolate = first_isolate(.)) %>%
- filter(first_isolate == TRUE,
- mo == as.mo("E. coli")) %>%
- group_by(age_group = age_groups(age)) %>%
- select(age_group,
+ mutate(first_isolate = first_isolate(.)) %>%
+ filter(first_isolate == TRUE,
+ mo == as.mo("E. coli")) %>%
+ group_by(age_group = age_groups(age)) %>%
+ select(age_group,
cipr) %>%
- ggplot_rsi(x = "age_group")
+ ggplot_rsi(x = "age_group")
# }
diff --git a/docs/reference/as.atc.html b/docs/reference/as.atc.html
index 4bfdb41f..82bbf371 100644
--- a/docs/reference/as.atc.html
+++ b/docs/reference/as.atc.html
@@ -163,7 +163,7 @@
- Use this function to determine the ATC code of one or more antibiotics. The data set antibiotics
will be searched for abbreviations, official names and trade names.
+ Use this function to determine the ATC code of one or more antibiotics. The data set antibiotics
will be searched for abbreviations, official names and trade names.
@@ -188,13 +188,13 @@
Details
- Use the ab_property
functions to get properties based on the returned ATC code, see Examples.
+ Use the ab_property
functions to get properties based on the returned ATC code, see Examples.
In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups.
Source: https://www.whocc.no/atc/structure_and_principles/
See also
- antibiotics
for the dataframe that is being used to determine ATCs.
+ antibiotics
for the dataframe that is being used to determine ATCs.
Examples
@@ -212,8 +212,8 @@
# Use ab_* functions to get a specific property based on an ATC code
Cipro <- as.atc("cipro") # returns `J01MA02`
-ab_official(Cipro) # returns "Ciprofloxacin"
-ab_umcg(Cipro) # returns "CIPR", the code used in the UMCG
+ab_official(Cipro) # returns "Ciprofloxacin"
+ab_umcg(Cipro) # returns "CIPR", the code used in the UMCG
# }
reference_df
- a data.frame
to use for extra reference when translating x
to a valid mo
. The first column can be any microbial name, code or ID (used in your analysis or organisation), the second column must be a valid mo
as found in the microorganisms
data set.
+ a data.frame
to use for extra reference when translating x
to a valid mo
. The first column can be any microbial name, code or ID (used in your analysis or organisation), the second column must be a valid mo
as found in the microorganisms
data set.
@@ -221,7 +221,7 @@
| ----> genus, a 5-7 letter acronym, mostly without vowels
----> taxonomic kingdom, either B (Bacteria), F (Fungi) or P (Protozoa)
- Use the mo_property
functions to get properties based on the returned code, see Examples.
Use the mo_property
functions to get properties based on the returned code, see Examples.
This function uses Artificial Intelligence (AI) to help getting fast and logical results. It tries to find matches in this order:
Taxonomic kingdom: it first searches in bacteria, then fungi, then protozoa
Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones
microorganisms
for the data.frame
with ITIS content that is being used to determine ID's.
-The mo_property
functions (like mo_genus
, mo_gramstain
) to get properties based on the returned code.
microorganisms
for the data.frame
with ITIS content that is being used to determine ID's.
+The mo_property
functions (like mo_genus
, mo_gramstain
) to get properties based on the returned code.
mo_property
functions (like mo_property
functions (like # NOT RUN { # What's the ATC of amoxicillin? -guess_atc("Amoxicillin") +guess_atc("Amoxicillin") # [1] "J01CA04" # oral DDD (Defined Daily Dose) of amoxicillin diff --git a/docs/reference/count.html b/docs/reference/count.html index b2849e8d..9dc60832 100644 --- a/docs/reference/count.html +++ b/docs/reference/count.html @@ -191,7 +191,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_... -+ one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with
as.rsi
if needed.one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with
as.rsi
if needed.also_single_tested @@ -199,11 +199,11 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_data -+ a
data.frame
containing columns with classrsi
(seeas.rsi
)a
data.frame
containing columns with classrsi
(seeas.rsi
)translate_ab -+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingabname
. This can be set withgetOption("get_antibiotic_names")
.a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingabname
. This can be set withgetOption("get_antibiotic_names")
.combine_IR @@ -221,13 +221,13 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_Details
-These functions are meant to count isolates. Use the
-portion_*
functions to calculate microbial resistance.-
n_rsi
is an alias ofcount_all
. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal ton_distinct
. Their function is equal tocount_S(...) + count_IR(...)
.+
count_df
takes any variable fromdata
that has an"rsi"
class (created withas.rsi
) and counts the amounts of R, I and S. The resulting tidy data (see Source)data.frame
will have three rows (S/I/R) and a column for each variable with class"rsi"
.These functions are meant to count isolates. Use the
+portion_*
functions to calculate microbial resistance.+
n_rsi
is an alias ofcount_all
. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal ton_distinct
. Their function is equal tocount_S(...) + count_IR(...)
.
count_df
takes any variable fromdata
that has an"rsi"
class (created withas.rsi
) and counts the amounts of R, I and S. The resulting tidy data (see Source)data.frame
will have three rows (S/I/R) and a column for each variable with class"rsi"
.See also
-+
portion_*
to calculate microbial resistance and susceptibility.
portion_*
to calculate microbial resistance and susceptibility.Examples
@@ -251,17 +251,17 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ # calculate back to count e.g. non-susceptible isolates. # This results in the same: count_IR(septic_patients$amox) -portion_IR(septic_patients$amox) * n_rsi(septic_patients$amox) +portion_IR(septic_patients$amox) * n_rsi(septic_patients$amox) library(dplyr) septic_patients %>% - group_by(hospital_id) %>% - summarise(R = count_R(cipr), + group_by(hospital_id) %>% + summarise(R = count_R(cipr), I = count_I(cipr), S = count_S(cipr), n1 = count_all(cipr), # the actual total; sum of all three n2 = n_rsi(cipr), # same - analogous to n_distinct - total = n()) # NOT the amount of tested isolates! + total = n()) # NOT the amount of tested isolates! # Count co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy. @@ -279,13 +279,13 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ # Get portions S/I/R immediately of all rsi columns septic_patients %>% - select(amox, cipr) %>% + select(amox, cipr) %>% count_df(translate = FALSE) # It also supports grouping variables septic_patients %>% - select(hospital_id, amox, cipr) %>% - group_by(hospital_id) %>% + select(hospital_id, amox, cipr) %>% + group_by(hospital_id) %>% count_df(translate = FALSE) # } diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index d9174890..6ab01938 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -199,7 +199,7 @@col_mo -+ column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.info diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 04ab01bd..2ec70f00 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -198,7 +198,7 @@col_mo -+ column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.col_testcode @@ -214,7 +214,7 @@col_keyantibiotics -+ column name of the key antibiotics to determine first weighted isolates, see
key_antibiotics
. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' (case insensitive). Usecol_keyantibiotics = FALSE
to prevent this.column name of the key antibiotics to determine first weighted isolates, see
key_antibiotics
. Defaults to the first column that starts with 'key' followed by 'ab' or 'antibiotics' (case insensitive). Usecol_keyantibiotics = FALSE
to prevent this.episode_days @@ -291,7 +291,7 @@ To conduct an analysis of antimicrobial resistance, you should only include theSee also
- +
key_antibiotics
Examples
@@ -302,11 +302,11 @@ To conduct an analysis of antimicrobial resistance, you should only include the library(dplyr) # Filter on first isolates: septic_patients %>% - mutate(first_isolate = first_isolate(., + mutate(first_isolate = first_isolate(., col_date = "date", col_patient_id = "patient_id", col_mo = "mo")) %>% - filter(first_isolate == TRUE) + filter(first_isolate == TRUE) # Which can be shortened to: septic_patients %>% @@ -317,15 +317,15 @@ To conduct an analysis of antimicrobial resistance, you should only include the # Now let's see if first isolates matter: A <- septic_patients %>% - group_by(hospital_id) %>% - summarise(count = n_rsi(gent), # gentamicin availability - resistance = portion_IR(gent)) # gentamicin resistance + group_by(hospital_id) %>% + summarise(count = n_rsi(gent), # gentamicin availability + resistance = portion_IR(gent)) # gentamicin resistance B <- septic_patients %>% filter_first_weighted_isolate() %>% # the 1st isolate filter - group_by(hospital_id) %>% - summarise(count = n_rsi(gent), # gentamicin availability - resistance = portion_IR(gent)) # gentamicin resistance + group_by(hospital_id) %>% + summarise(count = n_rsi(gent), # gentamicin availability + resistance = portion_IR(gent)) # gentamicin resistance # Have a look at A and B. # B is more reliable because every isolate is only counted once. @@ -337,7 +337,7 @@ To conduct an analysis of antimicrobial resistance, you should only include the # }# NOT RUN { # set key antibiotics to a new variable -tbl$keyab <- key_antibiotics(tbl) +tbl$keyab <- key_antibiotics(tbl) tbl$first_isolate <- first_isolate(tbl) diff --git a/docs/reference/freq.html b/docs/reference/freq.html index 5f6bed31..bbeabe99 100644 --- a/docs/reference/freq.html +++ b/docs/reference/freq.html @@ -317,34 +317,34 @@ # you could also use `select` or `pull` to get your variables septic_patients %>% - filter(hospital_id == "A") %>% - select(mo) %>% + filter(hospital_id == "A") %>% + select(mo) %>% freq() # multiple selected variables will be pasted together septic_patients %>% left_join_microorganisms %>% - filter(hospital_id == "A") %>% + filter(hospital_id == "A") %>% freq(genus, species) # group a variable and analyse another septic_patients %>% - group_by(hospital_id) %>% + group_by(hospital_id) %>% freq(gender) # get top 10 bugs of hospital A as a vector septic_patients %>% - filter(hospital_id == "A") %>% + filter(hospital_id == "A") %>% freq(mo) %>% top_freq(10) # save frequency table to an object years <- septic_patients %>% - mutate(year = format(date, "%Y")) %>% + mutate(year = format(date, "%Y")) %>% freq(year) @@ -395,11 +395,11 @@ # only get selected columns septic_patients %>% freq(hospital_id) %>% - select(item, percent) + select(item, percent) septic_patients %>% freq(hospital_id) %>% - select(-count, -cum_count) + select(-count, -cum_count) # check differences between frequency tables diff --git a/docs/reference/get_locale.html b/docs/reference/get_locale.html index cd3df960..b19d7c1f 100644 --- a/docs/reference/get_locale.html +++ b/docs/reference/get_locale.html @@ -163,7 +163,7 @@-diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index bca73c4b..8a068a95 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -193,11 +193,11 @@Determines the system language to be used for language-dependent output of AMR functions, like
+mo_gramstain
andmo_type
.Determines the system language to be used for language-dependent output of AMR functions, like
mo_gramstain
andmo_type
.data -+ a
data.frame
with column(s) of class"rsi"
(seeas.rsi
)a
data.frame
with column(s) of class"rsi"
(seeas.rsi
)position -+ position adjustment of bars, either
"fill"
(default whenfun
iscount_df
),"stack"
(default whenfun
isportion_df
) or"dodge"
position adjustment of bars, either
"fill"
(default whenfun
iscount_df
),"stack"
(default whenfun
isportion_df
) or"dodge"
x @@ -221,11 +221,11 @@translate_ab -+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations into, usingabname
. Default behaviour is to translate to official names according to the WHO. Usetranslate_ab = FALSE
to disable translation.a column name of the
antibiotics
data set to translate the antibiotic abbreviations into, usingabname
. Default behaviour is to translate to official names according to the WHO. Usetranslate_ab = FALSE
to disable translation.fun -+ function to transform
data
, eithercount_df
(default) orportion_df
function to transform
data
, eithercount_df
(default) orportion_df
nrow @@ -251,9 +251,9 @@Details
-At default, the names of antibiotics will be shown on the plots using
+abname
. This can be set with the optionget_antibiotic_names
(a logical value), so change it e.g. toFALSE
withoptions(get_antibiotic_names = FALSE)
.At default, the names of antibiotics will be shown on the plots using
abname
. This can be set with the optionget_antibiotic_names
(a logical value), so change it e.g. toFALSE
withoptions(get_antibiotic_names = FALSE)
.The functions
+
-geom_rsi
will take any variable from the data that has anrsi
class (created withas.rsi
) usingfun
(count_df
at default, can also beportion_df
) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.geom_rsi
will take any variable from the data that has anrsi
class (created withas.rsi
) usingfun
(count_df
at default, can also beportion_df
) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.
facet_rsi
creates 2d plots (at default based on S/I/R) usingfacet_wrap
.
scale_y_percent
transforms the y axis to a 0 to 100% range usingscale_continuous
.@@ -268,7 +268,7 @@ library(ggplot2) # get antimicrobial results for drugs against a UTI: -ggplot(septic_patients %>% select(amox, nitr, fosf, trim, cipr)) + +ggplot(septic_patients %>% select(amox, nitr, fosf, trim, cipr)) + geom_rsi() # prettify the plot using some additional functions: @@ -282,17 +282,17 @@ # or better yet, simplify this using the wrapper function - a single command: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi() # get only portions and no counts: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi(fun = portion_df) # add other ggplot2 parameters as you like: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi(width = 0.5, colour = "black", size = 1, @@ -301,25 +301,25 @@ # resistance of ciprofloxacine per age group septic_patients %>% - mutate(first_isolate = first_isolate(.)) %>% - filter(first_isolate == TRUE, - mo == as.mo("E. coli")) %>% + mutate(first_isolate = first_isolate(.)) %>% + filter(first_isolate == TRUE, + mo == as.mo("E. coli")) %>% # `age_group` is also a function of this package: - group_by(age_group = age_groups(age)) %>% - select(age_group, + group_by(age_group = age_groups(age)) %>% + select(age_group, cipr) %>% ggplot_rsi(x = "age_group") # }# NOT RUN { # for colourblind mode, use divergent colours from the viridis package: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi() + scale_fill_viridis_d() # it also supports groups (don't forget to use the group var on `x` or `facet`): septic_patients %>% - select(hospital_id, amox, nitr, fosf, trim, cipr) %>% - group_by(hospital_id) %>% + select(hospital_id, amox, nitr, fosf, trim, cipr) %>% + group_by(hospital_id) %>% ggplot_rsi(x = hospital_id, facet = Antibiotic, nrow = 1) + @@ -329,22 +329,22 @@ # genuine analysis: check 2 most prevalent microorganisms septic_patients %>% # create new bacterial ID's, with all CoNS under the same group (Becker et al.) - mutate(mo = as.mo(mo, Becker = TRUE)) %>% + mutate(mo = as.mo(mo, Becker = TRUE)) %>% # filter on top three bacterial ID's - filter(mo %in% top_freq(freq(.$mo), 3)) %>% + filter(mo %in% top_freq(freq(.$mo), 3)) %>% # determine first isolates - mutate(first_isolate = first_isolate(., + mutate(first_isolate = first_isolate(., col_date = "date", col_patient_id = "patient_id", col_mo = "mo")) %>% # filter on first isolates - filter(first_isolate == TRUE) %>% + filter(first_isolate == TRUE) %>% # get short MO names (like "E. coli") - mutate(mo = mo_shortname(mo, Becker = TRUE)) %>% + mutate(mo = mo_shortname(mo, Becker = TRUE)) %>% # select this short name and some antiseptic drugs - select(mo, cfur, gent, cipr) %>% + select(mo, cfur, gent, cipr) %>% # group by MO - group_by(mo) %>% + group_by(mo) %>% # plot the thing, putting MOs on the facet ggplot_rsi(x = Antibiotic, facet = mo, diff --git a/docs/reference/index.html b/docs/reference/index.html index 0bf64584..6d9ee1ff 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -286,7 +286,7 @@
scale_rsi_colours
sets colours to the bars: green for S, yellow for I and red for R, usingscale_brewer
.@@ -436,7 +436,7 @@ diff --git a/docs/reference/join.html b/docs/reference/join.html index bac48017..aee46a33 100644 --- a/docs/reference/join.html +++ b/docs/reference/join.html @@ -163,7 +163,7 @@ - Analysing the data
+Analysing your data
Functions for conducting AMR analysis
-@@ -188,7 +188,7 @@Join the dataset
+microorganisms
easily to an existing table or character vector.Join the dataset
microorganisms
easily to an existing table or character vector.by -+ a variable to join by - if left empty will search for a column with class
mo
(created withas.mo
) or will be"mo"
if that column name exists inx
, could otherwise be a column name ofx
with values that exist inmicroorganisms$mo
(likeby = "bacteria_id"
), or another column inmicroorganisms
(but then it should be named, likeby = c("my_genus_species" = "fullname")
)a variable to join by - if left empty will search for a column with class
mo
(created withas.mo
) or will be"mo"
if that column name exists inx
, could otherwise be a column name ofx
with values that exist inmicroorganisms$mo
(likeby = "bacteria_id"
), or another column inmicroorganisms
(but then it should be named, likeby = c("my_genus_species" = "fullname")
)suffix @@ -207,7 +207,7 @@Examples
# NOT RUN { -left_join_microorganisms(as.mo("K. pneumoniae")) +left_join_microorganisms(as.mo("K. pneumoniae")) left_join_microorganisms("B_KLBSL_PNE") library(dplyr) @@ -216,7 +216,7 @@ df <- data.frame(date = seq(from = as.Date("2018-01-01"), to = as.Date("2018-01-07"), by = 1), - bacteria = as.mo(c("S. aureus", "MRSA", "MSSA", "STAAUR", + bacteria = as.mo(c("S. aureus", "MRSA", "MSSA", "STAAUR", "E. coli", "E. coli", "E. coli")), stringsAsFactors = FALSE) colnames(df) diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 1919773d..bf4c020d 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -163,7 +163,7 @@-@@ -187,7 +187,7 @@These function can be used to determine first isolates (see
+first_isolate
). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first weighted isolates.These function can be used to determine first isolates (see
first_isolate
). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first weighted isolates.col_mo -+ column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.universal_1, universal_2, universal_3, universal_4, universal_5, universal_6 @@ -233,7 +233,7 @@Details
-The function
+key_antibiotics
returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared usingkey_antibiotics_equal
, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot ("."
). Thefirst_isolate
function only uses this function on the same microbial species from the same patient. Using this, an MRSA will be included after a susceptible S. aureus (MSSA) found within the same episode (seeepisode
parameter offirst_isolate
). Without key antibiotic comparison it wouldn't.The function
key_antibiotics
returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared usingkey_antibiotics_equal
, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot ("."
). Thefirst_isolate
function only uses this function on the same microbial species from the same patient. Using this, an MRSA will be included after a susceptible S. aureus (MSSA) found within the same episode (seeepisode
parameter offirst_isolate
). Without key antibiotic comparison it wouldn't.At default, the antibiotics that are used for Gram positive bacteria are (colum names):
"amox"
,"amcl"
,"cfur"
,"pita"
,"cipr"
,"trsu"
(until here is universal),"vanc"
,"teic"
,"tetr"
,"eryt"
,"oxac"
,"rifa"
.At default, the antibiotics that are used for Gram negative bacteria are (colum names):
@@ -251,7 +251,7 @@See also
- +
first_isolate
Examples
@@ -261,12 +261,12 @@ library(dplyr) # set key antibiotics to a new variable my_patients <- septic_patients %>% - mutate(keyab = key_antibiotics(.)) %>% - mutate( + mutate(keyab = key_antibiotics(.)) %>% + mutate( # now calculate first isolates - first_regular = first_isolate(., col_keyantibiotics = FALSE), + first_regular = first_isolate(., col_keyantibiotics = FALSE), # and first WEIGHTED isolates - first_weighted = first_isolate(., col_keyantibiotics = "keyab") + first_weighted = first_isolate(., col_keyantibiotics = "keyab") ) # Check the difference, in this data set it results in 7% more isolates: diff --git a/docs/reference/kurtosis.html b/docs/reference/kurtosis.html index 7bcbecdb..82f6e9e8 100644 --- a/docs/reference/kurtosis.html +++ b/docs/reference/kurtosis.html @@ -193,7 +193,7 @@See also
- +diff --git a/docs/reference/like.html b/docs/reference/like.html index 24cecf58..cdcdeda6 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -228,9 +228,9 @@ # get frequencies of bacteria whose name start with 'Ent' or 'ent' library(dplyr) septic_patients %>% - left_join_microorganisms() %>% - filter(genus %like% '^ent') %>% - freq(genus, species) + left_join_microorganisms() %>% + filter(genus %like% '^ent') %>% + freq(genus, species) # }
skewness
col_mo -+ column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.info @@ -537,7 +537,7 @@ library(dplyr) septic_patients %>% - mutate(EUCAST = mdro(.), + mutate(EUCAST = mdro(.), BRMO = brmo(.)) # } diff --git a/docs/reference/microorganisms.certe.html b/docs/reference/microorganisms.certe.html index 105a42b2..0ee93698 100644 --- a/docs/reference/microorganisms.certe.html +++ b/docs/reference/microorganisms.certe.html @@ -163,7 +163,7 @@-@@ -173,12 +173,12 @@A data set containing all bacteria codes of Certe MMB. These codes can be joined to data with an ID from
+microorganisms$mo
(usingleft_join_microorganisms
). GLIMS codes can also be translated to validMO
s withguess_mo
.A data set containing all bacteria codes of Certe MMB. These codes can be joined to data with an ID from
microorganisms$mo
(usingleft_join_microorganisms
). GLIMS codes can also be translated to validMO
s withguess_mo
.A
data.frame
with 2,665 observations and 2 variables:
certe
- -
Code of microorganism according to Certe MMB
mo
- +
Code of microorganism in
microorganisms
mo
Code of microorganism in
microorganisms
See also
- +diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index d3803b57..9150aa4b 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -163,7 +163,7 @@
as.mo
microorganisms
-@@ -185,7 +185,7 @@A data set containing the complete microbial taxonomy of the kingdoms Bacteria, Fungi and Protozoa. MO codes can be looked up using
+as.mo
.A data set containing the complete microbial taxonomy of the kingdoms Bacteria, Fungi and Protozoa. MO codes can be looked up using
as.mo
.subkingdom
Taxonomic subkingdom of the microorganism as found in ITIS, see Source
kingdom
Taxonomic kingdom of the microorganism as found in ITIS, see Source
gramstain
- Gram of microorganism, like
"Gram negative"
prevalence
+ An integer based on estimated prevalence of the microorganism in humans. Used internally by
as.mo
, otherwise quite meaningless. It has a value of 25 for manually added items and a value of 1000 for all unprevalent microorganisms whose genus was somewhere in the top 250 (with another species).prevalence
An integer based on estimated prevalence of the microorganism in humans. Used internally by
as.mo
, otherwise quite meaningless. It has a value of 25 for manually added items and a value of 1000 for all unprevalent microorganisms whose genus was somewhere in the top 250 (with another species).ref
@@ -203,7 +203,7 @@ This package contains the complete microbial taxonomic data (wi Author(s) and year of concerning publication as found in ITIS, see Source
See also
- +diff --git a/docs/reference/microorganisms.old.html b/docs/reference/microorganisms.old.html index 787704dc..66928578 100644 --- a/docs/reference/microorganisms.old.html +++ b/docs/reference/microorganisms.old.html @@ -163,7 +163,7 @@
as.mo
mo_property
microorganisms.umcg
-@@ -192,7 +192,7 @@ This package contains the complete microbial taxonomic data (wiA data set containing old (previously valid or accepted) taxonomic names according to ITIS. This data set is used internally by
+as.mo
.A data set containing old (previously valid or accepted) taxonomic names according to ITIS. This data set is used internally by
as.mo
.See also
- +diff --git a/docs/reference/microorganisms.umcg.html b/docs/reference/microorganisms.umcg.html index 081b91d6..e17e9ef4 100644 --- a/docs/reference/microorganisms.umcg.html +++ b/docs/reference/microorganisms.umcg.html @@ -163,7 +163,7 @@
as.mo
mo_property
microorganisms
-@@ -178,7 +178,7 @@A data set containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from
+microorganisms$mo
(usingleft_join_microorganisms
). GLIMS codes can also be translated to validMO
s withguess_mo
.A data set containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from
microorganisms$mo
(usingleft_join_microorganisms
). GLIMS codes can also be translated to validMO
s withguess_mo
.See also
- +diff --git a/docs/reference/mo_failures.html b/docs/reference/mo_failures.html index ebd64bf2..47fd4c94 100644 --- a/docs/reference/mo_failures.html +++ b/docs/reference/mo_failures.html @@ -163,7 +163,7 @@
as.mo
microorganisms.certe
microorganisms
-@@ -171,7 +171,7 @@Returns a vector of all failed attempts to coerce values to a valid MO code with
+as.mo
.Returns a vector of all failed attempts to coerce values to a valid MO code with
as.mo
.See also
- +diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index bcc59e01..46fe045d 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -163,19 +163,19 @@
as.mo
--Use these functions to return a specific property of a microorganism from the
+microorganisms
data set. All input values will be evaluated internally withas.mo
.Use these functions to return a specific property of a microorganism from the
microorganisms
data set. All input values will be evaluated internally withas.mo
.mo_fullname(x, language = get_locale(), ...) +mo_fullname(x, language = get_locale(), ...) -mo_shortname(x, language = get_locale(), ...) +mo_shortname(x, language = get_locale(), ...) -mo_subspecies(x, language = get_locale(), ...) +mo_subspecies(x, language = get_locale(), ...) -mo_species(x, language = get_locale(), ...) +mo_species(x, language = get_locale(), ...) -mo_genus(x, language = get_locale(), ...) +mo_genus(x, language = get_locale(), ...) mo_family(x, ...) @@ -189,9 +189,9 @@ mo_kingdom(x, ...) -mo_type(x, language = get_locale(), ...) +mo_type(x, language = get_locale(), ...) -mo_gramstain(x, language = get_locale(), ...) +mo_gramstain(x, language = get_locale(), ...) mo_TSN(x, ...) @@ -203,26 +203,26 @@ mo_taxonomy(x, ...) -mo_property(x, property = "fullname", language = get_locale(), ...)+mo_property(x, property = "fullname", language = get_locale(), ...)Arguments
@@ -266,7 +266,7 @@ This package contains the complete microbial taxonomic data (wi
x -+ any (vector of) text that can be coerced to a valid microorganism code with
as.mo
any (vector of) text that can be coerced to a valid microorganism code with
as.mo
language -+ language of the returned text, defaults to system language (see
get_locale
) and can also be set withgetOption("AMR_locale")
. Uselanguage = NULL
orlanguage = ""
to prevent translation.language of the returned text, defaults to system language (see
get_locale
) and can also be set withgetOption("AMR_locale")
. Uselanguage = NULL
orlanguage = ""
to prevent translation.... -+ other parameters passed on to
as.mo
other parameters passed on to
as.mo
property -+ one of the column names of one of the
microorganisms
data set or"shortname"
one of the column names of one of the
microorganisms
data set or"shortname"
See also
- +
microorganisms
Examples
diff --git a/docs/reference/mo_renamed.html b/docs/reference/mo_renamed.html index 1c2d9758..6eb3562f 100644 --- a/docs/reference/mo_renamed.html +++ b/docs/reference/mo_renamed.html @@ -163,7 +163,7 @@-@@ -171,7 +171,7 @@Returns a vector of all renamed items of the last coercion to valid MO codes with
+as.mo
.Returns a vector of all renamed items of the last coercion to valid MO codes with
as.mo
.See also
- +diff --git a/docs/reference/portion.html b/docs/reference/portion.html index 1e6fab8d..a48d0f8a 100644 --- a/docs/reference/portion.html +++ b/docs/reference/portion.html @@ -192,7 +192,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
as.mo
... -+ one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with
as.rsi
if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with
as.rsi
if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.minimum @@ -208,11 +208,11 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and portdata -+ a
data.frame
containing columns with classrsi
(seeas.rsi
)a
data.frame
containing columns with classrsi
(seeas.rsi
)translate_ab -+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingabname
. This can be set withgetOption("get_antibiotic_names")
.a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingabname
. This can be set withgetOption("get_antibiotic_names")
.combine_IR @@ -231,10 +231,10 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and portDetails
-Remember that you should filter your table to let it contain only first isolates! Use
-first_isolate
to determine them in your data set.These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the
-count
functions to count isolates. Low counts can infuence the outcome - theseportion
functions may camouflage this, since they only return the portion albeit being dependent on theminimum
parameter.-
portion_df
takes any variable fromdata
that has an"rsi"
class (created withas.rsi
) and calculates the portions R, I and S. The resulting tidy data (see Source)data.frame
will have three rows (S/I/R) and a column for each variable with class"rsi"
.The old
rsi
function is still available for backwards compatibility but is deprecated. +Remember that you should filter your table to let it contain only first isolates! Use
+first_isolate
to determine them in your data set.These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the
+count
functions to count isolates. Low counts can infuence the outcome - theseportion
functions may camouflage this, since they only return the portion albeit being dependent on theminimum
parameter.+
portion_df
takes any variable fromdata
that has an"rsi"
class (created withas.rsi
) and calculates the portions R, I and S. The resulting tidy data (see Source)data.frame
will have three rows (S/I/R) and a column for each variable with class"rsi"
.The old
@@ -250,7 +250,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and portrsi
function is still available for backwards compatibility but is deprecated.
To calculate the probability (p) of susceptibility of one antibiotic, we use this formula:See also
-+
count_*
to count resistant and susceptible isolates.
count_*
to count resistant and susceptible isolates.Examples
@@ -274,58 +274,58 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port septic_patients %>% portion_SI(amox) septic_patients %>% - group_by(hospital_id) %>% - summarise(p = portion_S(cipr), - n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr + group_by(hospital_id) %>% + summarise(p = portion_S(cipr), + n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr septic_patients %>% - group_by(hospital_id) %>% - summarise(R = portion_R(cipr, as_percent = TRUE), + group_by(hospital_id) %>% + summarise(R = portion_R(cipr, as_percent = TRUE), I = portion_I(cipr, as_percent = TRUE), S = portion_S(cipr, as_percent = TRUE), - n = n_rsi(cipr), # works like n_distinct in dplyr - total = n()) # NOT the amount of tested isolates! + n = n_rsi(cipr), # works like n_distinct in dplyr + total = n()) # NOT the amount of tested isolates! # Calculate co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy: septic_patients %>% portion_S(amcl) # S = 67.1% -septic_patients %>% count_all(amcl) # n = 1576 +septic_patients %>% count_all(amcl) # n = 1576 septic_patients %>% portion_S(gent) # S = 74.0% -septic_patients %>% count_all(gent) # n = 1855 +septic_patients %>% count_all(gent) # n = 1855 septic_patients %>% portion_S(amcl, gent) # S = 92.0% -septic_patients %>% count_all(amcl, gent) # n = 1517 +septic_patients %>% count_all(amcl, gent) # n = 1517 septic_patients %>% - group_by(hospital_id) %>% - summarise(cipro_p = portion_S(cipr, as_percent = TRUE), - cipro_n = count_all(cipr), + group_by(hospital_id) %>% + summarise(cipro_p = portion_S(cipr, as_percent = TRUE), + cipro_n = count_all(cipr), genta_p = portion_S(gent, as_percent = TRUE), - genta_n = count_all(gent), + genta_n = count_all(gent), combination_p = portion_S(cipr, gent, as_percent = TRUE), - combination_n = count_all(cipr, gent)) + combination_n = count_all(cipr, gent)) # Get portions S/I/R immediately of all rsi columns septic_patients %>% - select(amox, cipr) %>% + select(amox, cipr) %>% portion_df(translate = FALSE) # It also supports grouping variables septic_patients %>% - select(hospital_id, amox, cipr) %>% - group_by(hospital_id) %>% + select(hospital_id, amox, cipr) %>% + group_by(hospital_id) %>% portion_df(translate = FALSE) # }# NOT RUN { # calculate current empiric combination therapy of Helicobacter gastritis: my_table %>% - filter(first_isolate == TRUE, + filter(first_isolate == TRUE, genus == "Helicobacter") %>% - summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole - n = count_all(amox, metr)) + summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole + n = count_all(amox, metr)) # }