2018-12-29 22:24:19 +01:00
<!DOCTYPE html>
2019-02-20 13:57:23 +01:00
<!-- Generated by pkgdown: do not edit by hand --> < html lang = "en" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" >
< meta charset = "utf-8" >
2018-12-29 22:24:19 +01:00
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
2019-01-02 23:24:07 +01:00
< title > How to conduct AMR analysis • AMR (for R)< / title >
2019-02-20 13:57:23 +01:00
<!-- favicons --> < link rel = "icon" type = "image/png" sizes = "16x16" href = "../favicon-16x16.png" >
2018-12-29 22:24:19 +01:00
< link rel = "icon" type = "image/png" sizes = "32x32" href = "../favicon-32x32.png" >
2019-02-20 13:57:23 +01:00
< link rel = "apple-touch-icon" type = "image/png" sizes = "180x180" href = "../apple-touch-icon.png" >
< link rel = "apple-touch-icon" type = "image/png" sizes = "120x120" href = "../apple-touch-icon-120x120.png" >
< link rel = "apple-touch-icon" type = "image/png" sizes = "76x76" href = "../apple-touch-icon-76x76.png" >
< link rel = "apple-touch-icon" type = "image/png" sizes = "60x60" href = "../apple-touch-icon-60x60.png" >
<!-- jquery --> < script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity = "sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin = "anonymous" > < / script > <!-- Bootstrap --> < link href = "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel = "stylesheet" crossorigin = "anonymous" >
< script src = "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity = "sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin = "anonymous" > < / script > <!-- Font Awesome icons --> < link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity = "sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin = "anonymous" >
<!-- clipboard.js --> < script src = "https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity = "sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin = "anonymous" > < / script > <!-- sticky kit --> < script src = "https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity = "sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin = "anonymous" > < / script > <!-- pkgdown --> < link href = "../pkgdown.css" rel = "stylesheet" >
< script src = "../pkgdown.js" > < / script > <!-- docsearch --> < script src = "../docsearch.js" > < / script > < link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.css" integrity = "sha256-QOSRU/ra9ActyXkIBbiIB144aDBdtvXBcNc3OTNuX/Q=" crossorigin = "anonymous" >
2018-12-29 22:24:19 +01:00
< link href = "../docsearch.css" rel = "stylesheet" >
2019-02-20 13:57:23 +01:00
< script src = "https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity = "sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin = "anonymous" > < / script > < link href = "../extra.css" rel = "stylesheet" >
< script src = "../extra.js" > < / script > < meta property = "og:title" content = "How to conduct AMR analysis" >
< meta property = "og:description" content = "" >
< meta property = "og:image" content = "https://msberends.gitlab.io/AMR/logo.png" >
< meta name = "twitter:card" content = "summary" >
<!-- mathjax --> < script src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity = "sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin = "anonymous" > < / script > < script src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity = "sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin = "anonymous" > < / script > <!-- [if lt IE 9]>
2018-12-29 22:24:19 +01:00
< script src = "https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js" > < / script >
< script src = "https://oss.maxcdn.com/respond/1.4.2/respond.min.js" > < / script >
<![endif]-->
2019-02-20 13:57:23 +01:00
< / head >
< body >
2018-12-29 22:24:19 +01:00
< div class = "container template-article" >
2019-02-20 13:57:23 +01:00
< header > < div class = "navbar navbar-default navbar-fixed-top" role = "navigation" >
2018-12-29 22:24:19 +01:00
< div class = "container" >
< div class = "navbar-header" >
< button type = "button" class = "navbar-toggle collapsed" data-toggle = "collapse" data-target = "#navbar" aria-expanded = "false" >
< span class = "sr-only" > Toggle navigation< / span >
< span class = "icon-bar" > < / span >
< span class = "icon-bar" > < / span >
< span class = "icon-bar" > < / span >
< / button >
< span class = "navbar-brand" >
< a class = "navbar-link" href = "../index.html" > AMR (for R)< / a >
2019-02-18 02:33:37 +01:00
< span class = "version label label-default" data-toggle = "tooltip" data-placement = "bottom" title = "Released version" > 0.5.0.9018< / span >
2018-12-29 22:24:19 +01:00
< / span >
< / div >
< div id = "navbar" class = "navbar-collapse collapse" >
< ul class = "nav navbar-nav" >
2019-02-20 13:57:23 +01:00
< li >
2018-12-29 22:24:19 +01:00
< a href = "../index.html" >
< span class = "fa fa-home" > < / span >
Home
< / a >
< / li >
2019-01-02 23:24:07 +01:00
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" role = "button" aria-expanded = "false" >
< span class = "fa fa-question-circle" > < / span >
How to
2018-12-29 22:24:19 +01:00
2019-01-02 23:24:07 +01:00
< span class = "caret" > < / span >
2018-12-29 22:24:19 +01:00
< / a >
2019-01-02 23:24:07 +01:00
< ul class = "dropdown-menu" role = "menu" >
2019-02-20 13:57:23 +01:00
< li >
2019-01-02 23:24:07 +01:00
< a href = "../articles/AMR.html" >
< span class = "fa fa-directions" > < / span >
Conduct AMR analysis
< / a >
< / li >
< li >
2019-02-11 10:27:10 +01:00
< a href = "../articles/resistance_predict.html" >
2019-01-02 23:24:07 +01:00
< span class = "fa fa-dice" > < / span >
Predict antimicrobial resistance
< / a >
< / li >
2019-01-29 00:06:50 +01:00
< li >
< a href = "../articles/WHONET.html" >
< span class = "fa fa-globe-americas" > < / span >
Work with WHONET data
< / a >
< / li >
2019-02-14 15:18:17 +01:00
< li >
< a href = "../articles/SPSS.html" >
< span class = "fa fa-file-upload" > < / span >
Import data from SPSS/SAS/Stata
< / a >
< / li >
2019-01-02 23:24:07 +01:00
< li >
< a href = "../articles/EUCAST.html" >
< span class = "fa fa-exchange-alt" > < / span >
Apply EUCAST rules
< / a >
< / li >
< li >
2019-02-11 10:27:10 +01:00
< a href = "../reference/mo_property.html" >
2019-01-02 23:24:07 +01:00
< span class = "fa fa-bug" > < / span >
Get properties of a microorganism
< / a >
< / li >
< li >
2019-02-11 10:27:10 +01:00
< a href = "../reference/atc_property.html" >
2019-01-02 23:24:07 +01:00
< span class = "fa fa-capsules" > < / span >
Get properties of an antibiotic
< / a >
< / li >
< li >
< a href = "../articles/freq.html" >
< span class = "fa fa-sort-amount-down" > < / span >
Create frequency tables
< / a >
< / li >
< li >
< a href = "../articles/G_test.html" >
< span class = "fa fa-clipboard-check" > < / span >
Use the G-test
< / a >
< / li >
2019-01-11 20:37:23 +01:00
< li >
< a href = "../articles/benchmarks.html" >
< span class = "fa fa-shipping-fast" > < / span >
Other: benchmarks
< / a >
< / li >
2019-01-02 23:24:07 +01:00
< / ul >
2018-12-29 22:24:19 +01:00
< / li >
< li >
< a href = "../reference/" >
< span class = "fa fa-book-open" > < / span >
Manual
< / a >
< / li >
< li >
< a href = "../authors.html" >
< span class = "fa fa-users" > < / span >
Authors
< / a >
< / li >
< li >
< a href = "../news/" >
< span class = "far fa far fa-newspaper" > < / span >
Changelog
< / a >
< / li >
2019-01-02 23:24:07 +01:00
< / ul >
2019-02-20 13:57:23 +01:00
< ul class = "nav navbar-nav navbar-right" >
< li >
2018-12-29 22:24:19 +01:00
< a href = "https://gitlab.com/msberends/AMR" >
< span class = "fab fa fab fa-gitlab" > < / span >
Source Code
< / a >
< / li >
< li >
< a href = "../LICENSE-text.html" >
< span class = "fa fa-book" > < / span >
Licence
< / a >
< / li >
< / ul >
2019-02-20 13:57:23 +01:00
< form class = "navbar-form navbar-right" role = "search" >
2018-12-29 22:24:19 +01:00
< div class = "form-group" >
< input type = "search" class = "form-control" name = "search-input" id = "search-input" placeholder = "Search..." aria-label = "Search for..." autocomplete = "off" >
2019-02-20 13:57:23 +01:00
< / div >
2018-12-29 22:24:19 +01:00
< / form >
2019-02-20 13:57:23 +01:00
< / div >
<!-- /.nav - collapse -->
< / div >
<!-- /.container -->
< / div >
<!-- /.navbar -->
2018-12-29 22:24:19 +01:00
2019-02-20 13:57:23 +01:00
< / header > < div class = "row" >
2018-12-29 22:24:19 +01:00
< div class = "col-md-9 contents" >
< div class = "page-header toc-ignore" >
2019-01-02 23:24:07 +01:00
< h1 > How to conduct AMR analysis< / h1 >
2018-12-29 22:24:19 +01:00
< h4 class = "author" > Matthijs S. Berends< / h4 >
2019-02-25 10:42:57 +01:00
< h4 class = "date" > 25 February 2019< / h4 >
2018-12-29 22:24:19 +01:00
< div class = "hidden name" > < code > AMR.Rmd< / code > < / div >
< / div >
2019-02-25 10:42:57 +01:00
< p > < strong > Note:< / strong > values on this page will change with every website update since they are based on randomly created values and the page was written in < a href = "https://rmarkdown.rstudio.com/" > RMarkdown< / a > . However, the methodology remains unchanged. This page was generated on 25 February 2019.< / p >
2019-02-01 16:55:55 +01:00
< div id = "introduction" class = "section level1" >
2019-02-20 13:57:23 +01:00
< h1 class = "hasAnchor" >
< a href = "#introduction" class = "anchor" > < / a > Introduction< / h1 >
2018-12-31 01:48:53 +01:00
< p > For this tutorial, we will create fake demonstration data to work with.< / p >
< p > You can skip to < a href = "#cleaning-the-data" > Cleaning the data< / a > if you already have your own data ready. If you start your analysis, try to make the structure of your data generally look like this:< / p >
2019-02-20 13:57:23 +01:00
< table class = "table" >
< thead > < tr class = "header" >
2018-12-31 01:48:53 +01:00
< th align = "center" > date< / th >
< th align = "center" > patient_id< / th >
< th align = "center" > mo< / th >
< th align = "center" > amox< / th >
< th align = "center" > cipr< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2018-12-31 01:48:53 +01:00
< tbody >
< tr class = "odd" >
2019-02-25 10:42:57 +01:00
< td align = "center" > 2019-02-25< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > abcd< / td >
< td align = "center" > Escherichia coli< / td >
< td align = "center" > S< / td >
< td align = "center" > S< / td >
< / tr >
< tr class = "even" >
2019-02-25 10:42:57 +01:00
< td align = "center" > 2019-02-25< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > abcd< / td >
< td align = "center" > Escherichia coli< / td >
< td align = "center" > S< / td >
< td align = "center" > R< / td >
< / tr >
< tr class = "odd" >
2019-02-25 10:42:57 +01:00
< td align = "center" > 2019-02-25< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > efgh< / td >
< td align = "center" > Escherichia coli< / td >
< td align = "center" > R< / td >
< td align = "center" > S< / td >
< / tr >
< / tbody >
< / table >
< div id = "needed-r-packages" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#needed-r-packages" class = "anchor" > < / a > Needed R packages< / h2 >
2019-01-26 23:22:56 +01:00
< p > As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the < a href = "https://www.tidyverse.org" > tidyverse packages< / a > < a href = "https://dplyr.tidyverse.org/" > < code > dplyr< / code > < / a > and < a href = "https://ggplot2.tidyverse.org" > < code > ggplot2< / code > < / a > by < a href = "https://www.linkedin.com/in/hadleywickham/" > Dr Hadley Wickham< / a > . The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.< / p >
2018-12-31 01:48:53 +01:00
< p > Our < code > AMR< / code > package depends on these packages and even extends their use and functions.< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb1" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb1-1" title = "1" > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/library" > library< / a > < / span > (dplyr)< / a >
< a class = "sourceLine" id = "cb1-2" title = "2" > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/library" > library< / a > < / span > (ggplot2)< / a >
< a class = "sourceLine" id = "cb1-3" title = "3" > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/library" > library< / a > < / span > (AMR)< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb1-4" title = "4" > < / a >
< a class = "sourceLine" id = "cb1-5" title = "5" > < span class = "co" > # (if not yet installed, install with:)< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb1-6" title = "6" > < span class = "co" > # install.packages(c("tidyverse", "AMR"))< / span > < / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< / div >
< div id = "creation-of-data" class = "section level1" >
2019-02-20 13:57:23 +01:00
< h1 class = "hasAnchor" >
< a href = "#creation-of-data" class = "anchor" > < / a > Creation of data< / h1 >
2018-12-31 12:03:35 +01:00
< p > We will create some fake example data to use for analysis. For antimicrobial resistance analysis, we need at least: a patient ID, name or code of a microorganism, a date and antimicrobial results (an antibiogram). It could also include a specimen type (e.g. to filter on blood or urine), the ward type (e.g. to filter on ICUs).< / p >
2018-12-31 01:48:53 +01:00
< p > With additional columns (like a hospital name, the patients gender of even [well-defined] clinical properties) you can do a comparative analysis, as this tutorial will demonstrate too.< / p >
2019-02-01 16:55:55 +01:00
< div id = "patients" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#patients" class = "anchor" > < / a > Patients< / h2 >
2018-12-31 01:48:53 +01:00
< p > To start with patients, we need a unique list of patients.< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb2" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb2-1" title = "1" > patients < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/unlist" > unlist< / a > < / span > (< span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/lapply" > lapply< / a > < / span > (LETTERS, paste0, < span class = "dv" > 1< / span > < span class = "op" > :< / span > < span class = "dv" > 10< / span > ))< / a > < / code > < / pre > < / div >
2018-12-31 12:03:35 +01:00
< p > The < code > LETTERS< / code > object is available in R - it’ s a vector with 26 characters: < code > A< / code > to < code > Z< / code > . The < code > patients< / code > object we just created is now a vector of length 260, with values (patient IDs) varying from < code > A1< / code > to < code > Z10< / code > . Now we we also set the gender of our patients, by putting the ID and the gender in a table:< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb3" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb3-1" title = "1" > patients_table < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/data.frame" > data.frame< / a > < / span > (< span class = "dt" > patient_id =< / span > patients,< / a >
< a class = "sourceLine" id = "cb3-2" title = "2" > < span class = "dt" > gender =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/rep" > rep< / a > < / span > (< span class = "st" > "M"< / span > , < span class = "dv" > 135< / span > ),< / a >
< a class = "sourceLine" id = "cb3-3" title = "3" > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/rep" > rep< / a > < / span > (< span class = "st" > "F"< / span > , < span class = "dv" > 125< / span > )))< / a > < / code > < / pre > < / div >
2018-12-31 12:03:35 +01:00
< p > The first 135 patient IDs are now male, the other 125 are female.< / p >
2018-12-31 01:48:53 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< div id = "dates" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#dates" class = "anchor" > < / a > Dates< / h2 >
2018-12-31 01:48:53 +01:00
< p > Let’ s pretend that our data consists of blood cultures isolates from 1 January 2010 until 1 January 2018.< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb4" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb4-1" title = "1" > dates < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/seq" > seq< / a > < / span > (< span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/as.Date" > as.Date< / a > < / span > (< span class = "st" > "2010-01-01"< / span > ), < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/as.Date" > as.Date< / a > < / span > (< span class = "st" > "2018-01-01"< / span > ), < span class = "dt" > by =< / span > < span class = "st" > "day"< / span > )< / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< p > This < code > dates< / code > object now contains all days in our date range.< / p >
< div id = "microorganisms" class = "section level4" >
2019-02-20 13:57:23 +01:00
< h4 class = "hasAnchor" >
< a href = "#microorganisms" class = "anchor" > < / a > Microorganisms< / h4 >
2018-12-31 01:48:53 +01:00
< p > For this tutorial, we will uses four different microorganisms: < em > Escherichia coli< / em > , < em > Staphylococcus aureus< / em > , < em > Streptococcus pneumoniae< / em > , and < em > Klebsiella pneumoniae< / em > :< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb5" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb5-1" title = "1" > bacteria < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "st" > "Escherichia coli"< / span > , < span class = "st" > "Staphylococcus aureus"< / span > ,< / a >
< a class = "sourceLine" id = "cb5-2" title = "2" > < span class = "st" > "Streptococcus pneumoniae"< / span > , < span class = "st" > "Klebsiella pneumoniae"< / span > )< / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< / div >
< div id = "other-variables" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#other-variables" class = "anchor" > < / a > Other variables< / h2 >
2018-12-31 12:03:35 +01:00
< p > For completeness, we can also add the hospital where the patients was admitted and we need to define valid antibmicrobial results for our randomisation:< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb6" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb6-1" title = "1" > hospitals < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "st" > "Hospital A"< / span > , < span class = "st" > "Hospital B"< / span > , < span class = "st" > "Hospital C"< / span > , < span class = "st" > "Hospital D"< / span > )< / a >
< a class = "sourceLine" id = "cb6-2" title = "2" > ab_interpretations < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "st" > "S"< / span > , < span class = "st" > "I"< / span > , < span class = "st" > "R"< / span > )< / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< div id = "put-everything-together" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#put-everything-together" class = "anchor" > < / a > Put everything together< / h2 >
< p > Using the < code > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample()< / a > < / code > function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the < code > prob< / code > parameter.< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb7" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb7-1" title = "1" > sample_size < -< span class = "st" > < / span > < span class = "dv" > 20000< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb7-2" title = "2" > data < -< span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/data.frame" > data.frame< / a > < / span > (< span class = "dt" > date =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (dates, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ),< / a >
< a class = "sourceLine" id = "cb7-3" title = "3" > < span class = "dt" > patient_id =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (patients, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ),< / a >
< a class = "sourceLine" id = "cb7-4" title = "4" > < span class = "dt" > hospital =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (hospitals, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ,< / a >
< a class = "sourceLine" id = "cb7-5" title = "5" > < span class = "dt" > prob =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "fl" > 0.30< / span > , < span class = "fl" > 0.35< / span > , < span class = "fl" > 0.15< / span > , < span class = "fl" > 0.20< / span > )),< / a >
< a class = "sourceLine" id = "cb7-6" title = "6" > < span class = "dt" > bacteria =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (bacteria, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ,< / a >
< a class = "sourceLine" id = "cb7-7" title = "7" > < span class = "dt" > prob =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "fl" > 0.50< / span > , < span class = "fl" > 0.25< / span > , < span class = "fl" > 0.15< / span > , < span class = "fl" > 0.10< / span > )),< / a >
< a class = "sourceLine" id = "cb7-8" title = "8" > < span class = "dt" > amox =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (ab_interpretations, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ,< / a >
< a class = "sourceLine" id = "cb7-9" title = "9" > < span class = "dt" > prob =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "fl" > 0.60< / span > , < span class = "fl" > 0.05< / span > , < span class = "fl" > 0.35< / span > )),< / a >
< a class = "sourceLine" id = "cb7-10" title = "10" > < span class = "dt" > amcl =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (ab_interpretations, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ,< / a >
< a class = "sourceLine" id = "cb7-11" title = "11" > < span class = "dt" > prob =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "fl" > 0.75< / span > , < span class = "fl" > 0.10< / span > , < span class = "fl" > 0.15< / span > )),< / a >
< a class = "sourceLine" id = "cb7-12" title = "12" > < span class = "dt" > cipr =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (ab_interpretations, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ,< / a >
< a class = "sourceLine" id = "cb7-13" title = "13" > < span class = "dt" > prob =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "fl" > 0.80< / span > , < span class = "fl" > 0.00< / span > , < span class = "fl" > 0.20< / span > )),< / a >
< a class = "sourceLine" id = "cb7-14" title = "14" > < span class = "dt" > gent =< / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/sample.html" > sample< / a > < / span > (ab_interpretations, < span class = "dt" > size =< / span > sample_size, < span class = "dt" > replace =< / span > < span class = "ot" > TRUE< / span > ,< / a >
< a class = "sourceLine" id = "cb7-15" title = "15" > < span class = "dt" > prob =< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "fl" > 0.92< / span > , < span class = "fl" > 0.00< / span > , < span class = "fl" > 0.08< / span > ))< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb7-16" title = "16" > )< / a > < / code > < / pre > < / div >
2019-02-20 13:57:23 +01:00
< p > Using the < code > < a href = "https://dplyr.tidyverse.org/reference/join.html" > left_join()< / a > < / code > function from the < code > dplyr< / code > package, we can ‘ map’ the gender to the patient ID using the < code > patients_table< / code > object we created earlier:< / p >
< div class = "sourceCode" id = "cb8" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb8-1" title = "1" > data < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/join.html" > left_join< / a > < / span > (patients_table)< / a > < / code > < / pre > < / div >
< p > The resulting data set contains 5,000 blood culture isolates. With the < code > < a href = "https://www.rdocumentation.org/packages/utils/topics/head" > head()< / a > < / code > function we can preview the first 6 values of this data set:< / p >
< div class = "sourceCode" id = "cb9" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb9-1" title = "1" > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/utils/topics/head" > head< / a > < / span > (data)< / a > < / code > < / pre > < / div >
< table class = "table" >
< thead > < tr class = "header" >
2018-12-31 01:48:53 +01:00
< th align = "center" > date< / th >
< th align = "center" > patient_id< / th >
< th align = "center" > hospital< / th >
< th align = "center" > bacteria< / th >
< th align = "center" > amox< / th >
< th align = "center" > amcl< / th >
< th align = "center" > cipr< / th >
< th align = "center" > gent< / th >
2018-12-31 12:03:35 +01:00
< th align = "center" > gender< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2018-12-31 01:48:53 +01:00
< tbody >
< tr class = "odd" >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-05-27< / td >
< td align = "center" > C5< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > Escherichia coli< / td >
< td align = "center" > R< / td >
2019-02-20 14:18:11 +01:00
< td align = "center" > S< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > M< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-08-22< / td >
< td align = "center" > Q6< / td >
< td align = "center" > Hospital D< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > Escherichia coli< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-14 15:18:17 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > F< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2017-03-11< / td >
< td align = "center" > V9< / td >
< td align = "center" > Hospital A< / td >
< td align = "center" > Klebsiella pneumoniae< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > S< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
2019-02-21 23:32:30 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > F< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2012-12-25< / td >
< td align = "center" > A1< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > Escherichia coli< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-20 00:25:06 +01:00
< td align = "center" > S< / td >
2019-02-09 22:16:24 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > M< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-09-17< / td >
< td align = "center" > I5< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > Escherichia coli< / td >
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > R< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > M< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2017-05-19< / td >
< td align = "center" > O7< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > Hospital C< / td >
< td align = "center" > Streptococcus pneumoniae< / td >
2019-02-20 14:18:11 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > S< / td >
< td align = "center" > F< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< / tbody >
< / table >
< p > Now, let’ s start the cleaning and the analysis!< / p >
< / div >
< / div >
2019-02-01 16:55:55 +01:00
< div id = "cleaning-the-data" class = "section level1" >
2019-02-20 13:57:23 +01:00
< h1 class = "hasAnchor" >
< a href = "#cleaning-the-data" class = "anchor" > < / a > Cleaning the data< / h1 >
< p > Use the frequency table function < code > < a href = "../reference/freq.html" > freq()< / a > < / code > to look specifically for unique values in any variable. For example, for the < code > gender< / code > variable:< / p >
< div class = "sourceCode" id = "cb10" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb10-1" title = "1" > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/freq.html" > freq< / a > < / span > (gender) < span class = "co" > # this would be the same: freq(data$gender)< / span > < / a > < / code > < / pre > < / div >
2019-02-11 10:27:10 +01:00
< pre > < code > #> Frequency table of `gender` from a data.frame (20,000 x 9)
2019-02-12 15:38:31 +01:00
#>
2019-02-11 10:27:10 +01:00
#> Class: factor (numeric)
#> Length: 20,000 (of which NA: 0 = 0.00%)
2019-02-14 10:23:51 +01:00
#> Levels: 2: F, M
2019-02-11 10:27:10 +01:00
#> Unique: 2
#>
#> Item Count Percent Cum. Count Cum. Percent
#> --- ----- ------- -------- ----------- -------------
2019-02-25 16:07:21 +01:00
#> 1 M 10,437 52.2% 10,437 52.2%
#> 2 F 9,563 47.8% 20,000 100.0%< / code > < / pre >
2018-12-31 01:48:53 +01:00
< p > So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values < code > M< / code > and < code > F< / code > . From a researcher perspective: there are slightly more men. Nothing we didn’ t already know.< / p >
2019-02-20 13:57:23 +01:00
< p > The data is already quite clean, but we still need to transform some variables. The < code > bacteria< / code > column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The < code > < a href = "https://dplyr.tidyverse.org/reference/mutate.html" > mutate()< / a > < / code > function of the < code > dplyr< / code > package makes this really easy:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb12" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb12-1" title = "1" > data < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb12-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/mutate.html" > mutate< / a > < / span > (< span class = "dt" > bacteria =< / span > < span class = "kw" > < a href = "../reference/as.mo.html" > as.mo< / a > < / span > (bacteria))< / a > < / code > < / pre > < / div >
< p > We also want to transform the antibiotics, because in real life data we don’ t know if they are really clean. The < code > < a href = "../reference/as.rsi.html" > as.rsi()< / a > < / code > function ensures reliability and reproducibility in these kind of variables. The < code > < a href = "https://dplyr.tidyverse.org/reference/summarise_all.html" > mutate_at()< / a > < / code > will run the < code > < a href = "../reference/as.rsi.html" > as.rsi()< / a > < / code > function on defined variables:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb13" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb13-1" title = "1" > data < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb13-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/summarise_all.html" > mutate_at< / a > < / span > (< span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/vars.html" > vars< / a > < / span > (amox< span class = "op" > :< / span > gent), as.rsi)< / a > < / code > < / pre > < / div >
< p > Finally, we will apply < a href = "http://www.eucast.org/expert_rules_and_intrinsic_resistance/" > EUCAST rules< / a > on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the < code > < a href = "../reference/eucast_rules.html" > eucast_rules()< / a > < / code > function can also apply additional rules, like forcing < help title = "ATC: J01CA01" > ampicillin< / help > = R when < help title = "ATC: J01CR02" > amoxicillin/clavulanic acid< / help > = R.< / p >
< p > Because the amoxicillin (column < code > amox< / code > ) and amoxicillin/clavulanic acid (column < code > amcl< / code > ) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The < code > < a href = "../reference/eucast_rules.html" > eucast_rules()< / a > < / code > fixes this:< / p >
< div class = "sourceCode" id = "cb14" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb14-1" title = "1" > data < -< span class = "st" > < / span > < span class = "kw" > < a href = "../reference/eucast_rules.html" > eucast_rules< / a > < / span > (data, < span class = "dt" > col_mo =< / span > < span class = "st" > "bacteria"< / span > )< / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb14-2" title = "2" > < span class = "co" > #> < / span > < / a >
< a class = "sourceLine" id = "cb14-3" title = "3" > < span class = "co" > #> Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb14-4" title = "4" > < span class = "co" > #> < / span > < / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb14-5" title = "5" > < span class = "co" > #> EUCAST Clinical Breakpoints (v9.0, 2019)< / span > < / a >
< a class = "sourceLine" id = "cb14-6" title = "6" > < span class = "co" > #> Enterobacteriales (Order) (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-7" title = "7" > < span class = "co" > #> Staphylococcus (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-8" title = "8" > < span class = "co" > #> Enterococcus (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-9" title = "9" > < span class = "co" > #> Streptococcus groups A, B, C, G (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-10" title = "10" > < span class = "co" > #> Streptococcus pneumoniae (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-11" title = "11" > < span class = "co" > #> Viridans group streptococci (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-12" title = "12" > < span class = "co" > #> Haemophilus influenzae (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-13" title = "13" > < span class = "co" > #> Moraxella catarrhalis (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-14" title = "14" > < span class = "co" > #> Anaerobic Gram positives (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-15" title = "15" > < span class = "co" > #> Anaerobic Gram negatives (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-16" title = "16" > < span class = "co" > #> Pasteurella multocida (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-17" title = "17" > < span class = "co" > #> Campylobacter jejuni and C. coli (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-18" title = "18" > < span class = "co" > #> Aerococcus sanguinicola and A. urinae (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-19" title = "19" > < span class = "co" > #> Kingella kingae (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-20" title = "20" > < span class = "co" > #> < / span > < / a >
< a class = "sourceLine" id = "cb14-21" title = "21" > < span class = "co" > #> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)< / span > < / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb14-22" title = "22" > < span class = "co" > #> Table 1: Intrinsic resistance in Enterobacteriaceae (1294 changes)< / span > < / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb14-23" title = "23" > < span class = "co" > #> Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-24" title = "24" > < span class = "co" > #> Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)< / span > < / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb14-25" title = "25" > < span class = "co" > #> Table 4: Intrinsic resistance in Gram-positive bacteria (2675 changes)< / span > < / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb14-26" title = "26" > < span class = "co" > #> Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-27" title = "27" > < span class = "co" > #> Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-28" title = "28" > < span class = "co" > #> Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-29" title = "29" > < span class = "co" > #> Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-30" title = "30" > < span class = "co" > #> Table 12: Interpretive rules for aminoglycosides (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-31" title = "31" > < span class = "co" > #> Table 13: Interpretive rules for quinolones (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-32" title = "32" > < span class = "co" > #> < / span > < / a >
< a class = "sourceLine" id = "cb14-33" title = "33" > < span class = "co" > #> Other rules< / span > < / a >
< a class = "sourceLine" id = "cb14-34" title = "34" > < span class = "co" > #> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-35" title = "35" > < span class = "co" > #> Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-36" title = "36" > < span class = "co" > #> Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-37" title = "37" > < span class = "co" > #> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-38" title = "38" > < span class = "co" > #> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-39" title = "39" > < span class = "co" > #> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)< / span > < / a >
< a class = "sourceLine" id = "cb14-40" title = "40" > < span class = "co" > #> < / span > < / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb14-41" title = "41" > < span class = "co" > #> => EUCAST rules affected 7,390 out of 20,000 rows< / span > < / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb14-42" title = "42" > < span class = "co" > #> -> added 0 test results< / span > < / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb14-43" title = "43" > < span class = "co" > #> -> changed 3,969 test results (0 to S; 0 to I; 3,969 to R)< / span > < / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< div id = "adding-new-variables" class = "section level1" >
2019-02-20 13:57:23 +01:00
< h1 class = "hasAnchor" >
< a href = "#adding-new-variables" class = "anchor" > < / a > Adding new variables< / h1 >
2019-01-02 23:24:07 +01:00
< p > Now that we have the microbial ID, we can add some taxonomic properties:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb15" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb15-1" title = "1" > data < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb15-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/mutate.html" > mutate< / a > < / span > (< span class = "dt" > gramstain =< / span > < span class = "kw" > < a href = "../reference/mo_property.html" > mo_gramstain< / a > < / span > (bacteria),< / a >
< a class = "sourceLine" id = "cb15-3" title = "3" > < span class = "dt" > genus =< / span > < span class = "kw" > < a href = "../reference/mo_property.html" > mo_genus< / a > < / span > (bacteria),< / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb15-4" title = "4" > < span class = "dt" > species =< / span > < span class = "kw" > < a href = "../reference/mo_property.html" > mo_species< / a > < / span > (bacteria))< / a > < / code > < / pre > < / div >
2019-02-01 16:55:55 +01:00
< div id = "first-isolates" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#first-isolates" class = "anchor" > < / a > First isolates< / h2 >
2018-12-31 01:48:53 +01:00
< p > We also need to know which isolates we can < em > actually< / em > use for analysis.< / p >
2018-12-31 12:03:35 +01:00
< p > To conduct an analysis of antimicrobial resistance, you must < a href = "https://www.ncbi.nlm.nih.gov/pubmed/17304462" > only include the first isolate of every patient per episode< / a > (Hindler < em > et al.< / em > , Clin Infect Dis. 2007). If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following weeks (yes, some countries like the Netherlands have these blood drawing policies). The resistance percentage of oxacillin of all isolates would be overestimated, because you included this MRSA more than once. It would clearly be < a href = "https://en.wikipedia.org/wiki/Selection_bias" > selection bias< / a > .< / p >
2018-12-31 01:48:53 +01:00
< p > The Clinical and Laboratory Standards Institute (CLSI) appoints this as follows:< / p >
< blockquote >
2019-01-02 23:24:07 +01:00
< p > < em > (…) When preparing a cumulative antibiogram to guide clinical decisions about empirical antimicrobial therapy of initial infections, < strong > only the first isolate of a given species per patient, per analysis period (eg, one year) should be included, irrespective of body site, antimicrobial susceptibility profile, or other phenotypical characteristics (eg, biotype)< / strong > . The first isolate is easily identified, and cumulative antimicrobial susceptibility test data prepared using the first isolate are generally comparable to cumulative antimicrobial susceptibility test data calculated by other methods, providing duplicate isolates are excluded.< / em > < br > < a href = "https://clsi.org/standards/products/microbiology/documents/m39/" > M39-A4 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition. CLSI, 2014. Chapter 6.4< / a > < / p >
2018-12-31 01:48:53 +01:00
< / blockquote >
2019-02-20 13:57:23 +01:00
< p > This < code > AMR< / code > package includes this methodology with the < code > < a href = "../reference/first_isolate.html" > first_isolate()< / a > < / code > function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb16" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb16-1" title = "1" > data < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb16-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/mutate.html" > mutate< / a > < / span > (< span class = "dt" > first =< / span > < span class = "kw" > < a href = "../reference/first_isolate.html" > first_isolate< / a > < / span > (.))< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb16-3" title = "3" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `bacteria` as input for `col_mo`.< / span > < / a >
< a class = "sourceLine" id = "cb16-4" title = "4" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `date` as input for `col_date`.< / span > < / a >
< a class = "sourceLine" id = "cb16-5" title = "5" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `patient_id` as input for `col_patient_id`.< / span > < / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb16-6" title = "6" > < span class = "co" > #> => Found 5,670 first isolates (28.4% of total)< / span > < / a > < / code > < / pre > < / div >
2019-02-25 15:52:32 +01:00
< p > So only 28.4% is suitable for resistance analysis! We can now filter on it with the < code > < a href = "https://dplyr.tidyverse.org/reference/filter.html" > filter()< / a > < / code > function, also from the < code > dplyr< / code > package:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb17" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb17-1" title = "1" > data_1st < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb17-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/filter.html" > filter< / a > < / span > (first < span class = "op" > ==< / span > < span class = "st" > < / span > < span class = "ot" > TRUE< / span > )< / a > < / code > < / pre > < / div >
< p > For future use, the above two syntaxes can be shortened with the < code > < a href = "../reference/first_isolate.html" > filter_first_isolate()< / a > < / code > function:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb18" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb18-1" title = "1" > data_1st < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb18-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/first_isolate.html" > filter_first_isolate< / a > < / span > ()< / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< div id = "first-weighted-isolates" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#first-weighted-isolates" class = "anchor" > < / a > First < em > weighted< / em > isolates< / h2 >
2019-01-02 23:24:07 +01:00
< p > We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Imagine this data, sorted on date:< / p >
2019-02-20 13:57:23 +01:00
< table class = "table" >
< thead > < tr class = "header" >
2018-12-31 01:48:53 +01:00
< th align = "center" > isolate< / th >
< th align = "center" > date< / th >
< th align = "center" > patient_id< / th >
< th align = "center" > bacteria< / th >
< th align = "center" > amox< / th >
< th align = "center" > amcl< / th >
< th align = "center" > cipr< / th >
< th align = "center" > gent< / th >
< th align = "center" > first< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2018-12-31 01:48:53 +01:00
< tbody >
< tr class = "odd" >
< td align = "center" > 1< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-03-10< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > R< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > S< / td >
< td align = "center" > TRUE< / td >
< / tr >
< tr class = "even" >
< td align = "center" > 2< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-03-12< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > I< / td >
< td align = "center" > I< / td >
2019-02-11 10:27:10 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-01-29 20:20:09 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 3< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-06-18< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > I< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
2019-01-26 23:22:56 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 4< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-10-16< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-08 16:06:54 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-04 12:24:07 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 5< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-11-12< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-01-27 13:33:43 +01:00
< td align = "center" > S< / td >
2019-02-20 00:25:06 +01:00
< td align = "center" > S< / td >
2019-02-11 10:27:10 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 6< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-11-24< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > I< / td >
2019-01-29 20:20:09 +01:00
< td align = "center" > S< / td >
2019-02-20 00:25:06 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 7< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-02-24< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-14 15:18:17 +01:00
< td align = "center" > S< / td >
2019-02-21 23:32:30 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 8< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-03-30< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > R< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > TRUE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 9< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-08-09< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > R< / td >
2019-02-20 00:04:48 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 10< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-08-14< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< / tbody >
< / table >
2019-02-20 13:57:23 +01:00
< p > Only 2 isolates are marked as ‘ first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The < code > < a href = "../reference/key_antibiotics.html" > key_antibiotics()< / a > < / code > function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.< / p >
< p > If a column exists with a name like ‘ key(…)ab’ the < code > < a href = "../reference/first_isolate.html" > first_isolate()< / a > < / code > function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb19" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb19-1" title = "1" > data < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb19-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/mutate.html" > mutate< / a > < / span > (< span class = "dt" > keyab =< / span > < span class = "kw" > < a href = "../reference/key_antibiotics.html" > key_antibiotics< / a > < / span > (.)) < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
< a class = "sourceLine" id = "cb19-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/mutate.html" > mutate< / a > < / span > (< span class = "dt" > first_weighted =< / span > < span class = "kw" > < a href = "../reference/first_isolate.html" > first_isolate< / a > < / span > (.))< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb19-4" title = "4" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `bacteria` as input for `col_mo`.< / span > < / a >
2019-02-23 21:49:02 +01:00
< a class = "sourceLine" id = "cb19-5" title = "5" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `bacteria` as input for `col_mo`.< / span > < / a >
< a class = "sourceLine" id = "cb19-6" title = "6" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `date` as input for `col_date`.< / span > < / a >
< a class = "sourceLine" id = "cb19-7" title = "7" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `patient_id` as input for `col_patient_id`.< / span > < / a >
< a class = "sourceLine" id = "cb19-8" title = "8" > < span class = "co" > #> < / span > < span class = "al" > NOTE< / span > < span class = "co" > : Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.< / span > < / a >
< a class = "sourceLine" id = "cb19-9" title = "9" > < span class = "co" > #> [Criterion] Inclusion based on key antibiotics, ignoring I.< / span > < / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb19-10" title = "10" > < span class = "co" > #> => Found 15,887 first weighted isolates (79.4% of total)< / span > < / a > < / code > < / pre > < / div >
2019-02-20 13:57:23 +01:00
< table class = "table" >
< thead > < tr class = "header" >
2018-12-31 01:48:53 +01:00
< th align = "center" > isolate< / th >
< th align = "center" > date< / th >
< th align = "center" > patient_id< / th >
< th align = "center" > bacteria< / th >
< th align = "center" > amox< / th >
< th align = "center" > amcl< / th >
< th align = "center" > cipr< / th >
< th align = "center" > gent< / th >
< th align = "center" > first< / th >
< th align = "center" > first_weighted< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2018-12-31 01:48:53 +01:00
< tbody >
< tr class = "odd" >
< td align = "center" > 1< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-03-10< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > R< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > S< / td >
< td align = "center" > TRUE< / td >
< td align = "center" > TRUE< / td >
< / tr >
< tr class = "even" >
< td align = "center" > 2< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-03-12< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > I< / td >
< td align = "center" > I< / td >
2019-02-11 10:27:10 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-01-29 20:20:09 +01:00
< td align = "center" > FALSE< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > TRUE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 3< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-06-18< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > I< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
2019-01-26 23:22:56 +01:00
< td align = "center" > FALSE< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 4< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-10-16< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-08 16:06:54 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
< td align = "center" > S< / td >
< td align = "center" > FALSE< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 5< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-11-12< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-01-27 13:33:43 +01:00
< td align = "center" > S< / td >
2019-02-20 00:25:06 +01:00
< td align = "center" > S< / td >
2019-02-11 10:27:10 +01:00
< td align = "center" > FALSE< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 6< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2010-11-24< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > I< / td >
2019-01-29 20:20:09 +01:00
< td align = "center" > S< / td >
2019-02-20 00:25:06 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > FALSE< / td >
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 7< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-02-24< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-04 12:24:07 +01:00
< td align = "center" > S< / td >
2019-02-21 23:32:30 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > FALSE< / td >
< td align = "center" > FALSE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 8< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-03-30< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > R< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > TRUE< / td >
2019-02-22 22:12:10 +01:00
< td align = "center" > TRUE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > 9< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-08-09< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > R< / td >
2019-02-20 00:04:48 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > FALSE< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > TRUE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > 10< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 2011-08-14< / td >
< td align = "center" > F7< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > FALSE< / td >
2019-02-20 13:57:23 +01:00
< td align = "center" > TRUE< / td >
2018-12-31 01:48:53 +01:00
< / tr >
< / tbody >
< / table >
2019-02-25 16:07:21 +01:00
< p > Instead of 2, now 5 isolates are flagged. In total, 79.4% of all isolates are marked ‘ first weighted’ - 51.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.< / p >
2019-02-20 13:57:23 +01:00
< p > As with < code > < a href = "../reference/first_isolate.html" > filter_first_isolate()< / a > < / code > , there’ s a shortcut for this new algorithm too:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb20" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb20-1" title = "1" > data_1st < -< span class = "st" > < / span > data < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb20-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/first_isolate.html" > filter_first_weighted_isolate< / a > < / span > ()< / a > < / code > < / pre > < / div >
2019-02-25 16:07:21 +01:00
< p > So we end up with 15,887 isolates for analysis.< / p >
2018-12-31 01:48:53 +01:00
< p > We can remove unneeded columns:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb21" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb21-1" title = "1" > data_1st < -< span class = "st" > < / span > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb21-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/select.html" > select< / a > < / span > (< span class = "op" > -< / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (first, keyab))< / a > < / code > < / pre > < / div >
2018-12-31 01:48:53 +01:00
< p > Now our data looks like:< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb22" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb22-1" title = "1" > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/utils/topics/head" > head< / a > < / span > (data_1st)< / a > < / code > < / pre > < / div >
< table class = "table" >
< thead > < tr class = "header" >
2019-02-25 16:07:21 +01:00
< th > < / th >
2018-12-31 01:48:53 +01:00
< th align = "center" > date< / th >
< th align = "center" > patient_id< / th >
< th align = "center" > hospital< / th >
< th align = "center" > bacteria< / th >
< th align = "center" > amox< / th >
< th align = "center" > amcl< / th >
< th align = "center" > cipr< / th >
< th align = "center" > gent< / th >
2018-12-31 12:03:35 +01:00
< th align = "center" > gender< / th >
2018-12-31 01:48:53 +01:00
< th align = "center" > gramstain< / th >
2019-01-02 23:24:07 +01:00
< th align = "center" > genus< / th >
< th align = "center" > species< / th >
2018-12-31 01:48:53 +01:00
< th align = "center" > first_weighted< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2018-12-31 01:48:53 +01:00
< tbody >
< tr class = "odd" >
2019-02-25 16:07:21 +01:00
< td > 1< / td >
< td align = "center" > 2011-05-27< / td >
< td align = "center" > C5< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > B_ESCHR_COL< / td >
< td align = "center" > R< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-14 15:18:17 +01:00
< td align = "center" > S< / td >
2019-02-23 21:49:02 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > M< / td >
< td align = "center" > Gram negative< / td >
< td align = "center" > Escherichia< / td >
< td align = "center" > coli< / td >
2019-01-11 20:37:23 +01:00
< td align = "center" > TRUE< / td >
< / tr >
2019-02-08 16:06:54 +01:00
< tr class = "even" >
2019-02-25 16:07:21 +01:00
< td > 2< / td >
< td align = "center" > 2010-08-22< / td >
< td align = "center" > Q6< / td >
< td align = "center" > Hospital D< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > B_ESCHR_COL< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-21 18:55:52 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > F< / td >
< td align = "center" > Gram negative< / td >
< td align = "center" > Escherichia< / td >
< td align = "center" > coli< / td >
2018-12-31 01:48:53 +01:00
< td align = "center" > TRUE< / td >
< / tr >
2019-02-23 18:08:28 +01:00
< tr class = "odd" >
2019-02-25 16:07:21 +01:00
< td > 6< / td >
< td align = "center" > 2017-05-19< / td >
< td align = "center" > O7< / td >
< td align = "center" > Hospital C< / td >
< td align = "center" > B_STRPT_PNE< / td >
2019-02-14 15:18:17 +01:00
< td align = "center" > S< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > R< / td >
< td align = "center" > F< / td >
< td align = "center" > Gram positive< / td >
< td align = "center" > Streptococcus< / td >
< td align = "center" > pneumoniae< / td >
2019-02-14 15:18:17 +01:00
< td align = "center" > TRUE< / td >
< / tr >
2019-02-23 18:08:28 +01:00
< tr class = "even" >
2019-02-25 16:07:21 +01:00
< td > 8< / td >
< td align = "center" > 2011-01-19< / td >
< td align = "center" > Q7< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > B_ESCHR_COL< / td >
< td align = "center" > S< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > S< / td >
< td align = "center" > S< / td >
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > F< / td >
< td align = "center" > Gram negative< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > Escherichia< / td >
< td align = "center" > coli< / td >
2019-02-23 18:08:28 +01:00
< td align = "center" > TRUE< / td >
< / tr >
2019-02-18 02:33:37 +01:00
< tr class = "odd" >
2019-02-25 16:07:21 +01:00
< td > 9< / td >
< td align = "center" > 2014-06-24< / td >
< td align = "center" > S9< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > B_STRPT_PNE< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > R< / td >
2019-02-25 10:42:57 +01:00
< td align = "center" > R< / td >
2019-02-22 22:12:10 +01:00
< td align = "center" > S< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > R< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > F< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > Gram positive< / td >
< td align = "center" > Streptococcus< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > pneumoniae< / td >
2019-02-18 02:33:37 +01:00
< td align = "center" > TRUE< / td >
< / tr >
< tr class = "even" >
2019-02-25 16:07:21 +01:00
< td > 10< / td >
< td align = "center" > 2011-10-01< / td >
< td align = "center" > O10< / td >
< td align = "center" > Hospital B< / td >
< td align = "center" > B_STPHY_AUR< / td >
< td align = "center" > R< / td >
2019-02-23 16:02:31 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > R< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > S< / td >
2019-02-25 15:52:32 +01:00
< td align = "center" > F< / td >
< td align = "center" > Gram positive< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > Staphylococcus< / td >
< td align = "center" > aureus< / td >
2019-01-25 13:18:41 +01:00
< td align = "center" > TRUE< / td >
< / tr >
2018-12-31 01:48:53 +01:00
< / tbody >
< / table >
< p > Time for the analysis!< / p >
< / div >
< / div >
2019-02-01 16:55:55 +01:00
< div id = "analysing-the-data" class = "section level1" >
2019-02-20 13:57:23 +01:00
< h1 class = "hasAnchor" >
< a href = "#analysing-the-data" class = "anchor" > < / a > Analysing the data< / h1 >
2019-02-01 16:55:55 +01:00
< p > You might want to start by getting an idea of how the data is distributed. It’ s an important start, because it also decides how you will continue your analysis.< / p >
< div id = "dispersion-of-species" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#dispersion-of-species" class = "anchor" > < / a > Dispersion of species< / h2 >
< p > To just get an idea how the species are distributed, create a frequency table with our < code > < a href = "../reference/freq.html" > freq()< / a > < / code > function. We created the < code > genus< / code > and < code > species< / code > column earlier based on the microbial ID. With < code > < a href = "https://www.rdocumentation.org/packages/base/topics/paste" > paste()< / a > < / code > , we can concatenate them together.< / p >
< p > The < code > < a href = "../reference/freq.html" > freq()< / a > < / code > function can be used like the base R language was intended:< / p >
< div class = "sourceCode" id = "cb23" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb23-1" title = "1" > < span class = "kw" > < a href = "../reference/freq.html" > freq< / a > < / span > (< span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/paste" > paste< / a > < / span > (data_1st< span class = "op" > $< / span > genus, data_1st< span class = "op" > $< / span > species))< / a > < / code > < / pre > < / div >
2019-01-02 23:24:07 +01:00
< p > Or can be used like the < code > dplyr< / code > way, which is easier readable:< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb24" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb24-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/freq.html" > freq< / a > < / span > (genus, species)< / a > < / code > < / pre > < / div >
2019-02-25 16:07:21 +01:00
< p > < strong > Frequency table of < code > genus< / code > and < code > species< / code > from a < code > data.frame< / code > (15,887 x 13)< / strong > < / p >
2019-02-20 13:57:23 +01:00
< p > Columns: 2< br >
2019-02-25 16:07:21 +01:00
Length: 15,887 (of which NA: 0 = 0.00%)< br >
2019-01-02 23:24:07 +01:00
Unique: 4< / p >
2019-02-20 13:57:23 +01:00
< p > Shortest: 16< br >
2019-01-02 23:24:07 +01:00
Longest: 24< / p >
2019-02-20 13:57:23 +01:00
< table class = "table" >
< thead > < tr class = "header" >
2019-01-02 23:24:07 +01:00
< th align = "left" > < / th >
< th align = "left" > Item< / th >
< th align = "right" > Count< / th >
< th align = "right" > Percent< / th >
< th align = "right" > Cum. Count< / th >
< th align = "right" > Cum. Percent< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2019-01-02 23:24:07 +01:00
< tbody >
< tr class = "odd" >
< td align = "left" > 1< / td >
< td align = "left" > Escherichia coli< / td >
2019-02-25 16:07:21 +01:00
< td align = "right" > 7,900< / td >
< td align = "right" > 49.7%< / td >
< td align = "right" > 7,900< / td >
< td align = "right" > 49.7%< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "left" > 2< / td >
< td align = "left" > Staphylococcus aureus< / td >
2019-02-25 16:07:21 +01:00
< td align = "right" > 3,951< / td >
< td align = "right" > 24.9%< / td >
< td align = "right" > 11,851< / td >
< td align = "right" > 74.6%< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "odd" >
< td align = "left" > 3< / td >
< td align = "left" > Streptococcus pneumoniae< / td >
2019-02-25 16:07:21 +01:00
< td align = "right" > 2,413< / td >
< td align = "right" > 15.2%< / td >
< td align = "right" > 14,264< / td >
< td align = "right" > 89.8%< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "left" > 4< / td >
< td align = "left" > Klebsiella pneumoniae< / td >
2019-02-25 16:07:21 +01:00
< td align = "right" > 1,623< / td >
< td align = "right" > 10.2%< / td >
< td align = "right" > 15,887< / td >
2019-01-02 23:24:07 +01:00
< td align = "right" > 100.0%< / td >
< / tr >
< / tbody >
< / table >
2019-02-01 16:55:55 +01:00
< / div >
< div id = "resistance-percentages" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#resistance-percentages" class = "anchor" > < / a > Resistance percentages< / h2 >
2019-01-02 23:24:07 +01:00
< p > The functions < code > portion_R< / code > , < code > portion_RI< / code > , < code > portion_I< / code > , < code > portion_IS< / code > and < code > portion_S< / code > can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb25" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb25-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_IR< / a > < / span > (amox)< / a >
2019-02-25 16:07:21 +01:00
< a class = "sourceLine" id = "cb25-2" title = "2" > < span class = "co" > #> [1] 0.4763014< / span > < / a > < / code > < / pre > < / div >
2019-02-20 13:57:23 +01:00
< p > Or can be used in conjuction with < code > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by()< / a > < / code > and < code > < a href = "https://dplyr.tidyverse.org/reference/summarise.html" > summarise()< / a > < / code > , both from the < code > dplyr< / code > package:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb26" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb26-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb26-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (hospital) < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
< a class = "sourceLine" id = "cb26-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/summarise.html" > summarise< / a > < / span > (< span class = "dt" > amoxicillin =< / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_IR< / a > < / span > (amox))< / a > < / code > < / pre > < / div >
< table class = "table" >
< thead > < tr class = "header" >
2019-01-02 23:24:07 +01:00
< th align = "center" > hospital< / th >
< th align = "center" > amoxicillin< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2019-01-02 23:24:07 +01:00
< tbody >
< tr class = "odd" >
< td align = "center" > Hospital A< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4774125< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4762754< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > Hospital C< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4630957< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > Hospital D< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4845070< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< / tbody >
< / table >
2019-02-20 13:57:23 +01:00
< p > Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the < code > < a href = "../reference/count.html" > n_rsi()< / a > < / code > can be used, which works exactly like < code > < a href = "https://dplyr.tidyverse.org/reference/n_distinct.html" > n_distinct()< / a > < / code > from the < code > dplyr< / code > package. It counts all isolates available for every group (i.e. values S, I or R):< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb27" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb27-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb27-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (hospital) < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
< a class = "sourceLine" id = "cb27-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/summarise.html" > summarise< / a > < / span > (< span class = "dt" > amoxicillin =< / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_IR< / a > < / span > (amox),< / a >
< a class = "sourceLine" id = "cb27-4" title = "4" > < span class = "dt" > available =< / span > < span class = "kw" > < a href = "../reference/count.html" > n_rsi< / a > < / span > (amox))< / a > < / code > < / pre > < / div >
< table class = "table" >
< thead > < tr class = "header" >
2019-01-02 23:24:07 +01:00
< th align = "center" > hospital< / th >
< th align = "center" > amoxicillin< / th >
< th align = "center" > available< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2019-01-02 23:24:07 +01:00
< tbody >
< tr class = "odd" >
< td align = "center" > Hospital A< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4774125< / td >
< td align = "center" > 4715< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > Hospital B< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4762754< / td >
< td align = "center" > 5606< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > Hospital C< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4630957< / td >
< td align = "center" > 2371< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > Hospital D< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.4845070< / td >
< td align = "center" > 3195< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< / tbody >
< / table >
< p > These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb28" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb28-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb28-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (genus) < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
< a class = "sourceLine" id = "cb28-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/summarise.html" > summarise< / a > < / span > (< span class = "dt" > amoxicillin =< / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_S< / a > < / span > (amcl),< / a >
< a class = "sourceLine" id = "cb28-4" title = "4" > < span class = "dt" > gentamicin =< / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_S< / a > < / span > (gent),< / a >
< a class = "sourceLine" id = "cb28-5" title = "5" > < span class = "st" > "amox + gent"< / span > =< span class = "st" > < / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_S< / a > < / span > (amcl, gent))< / a > < / code > < / pre > < / div >
< table class = "table" >
< thead > < tr class = "header" >
2019-01-02 23:24:07 +01:00
< th align = "center" > genus< / th >
< th align = "center" > amoxicillin< / th >
< th align = "center" > gentamicin< / th >
< th align = "center" > amox + gent< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2019-01-02 23:24:07 +01:00
< tbody >
< tr class = "odd" >
< td align = "center" > Escherichia< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.7267089< / td >
< td align = "center" > 0.9002532< / td >
< td align = "center" > 0.9720253< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > Klebsiella< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.7233518< / td >
< td align = "center" > 0.8983364< / td >
< td align = "center" > 0.9741220< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "odd" >
< td align = "center" > Staphylococcus< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.7296887< / td >
< td align = "center" > 0.9248292< / td >
< td align = "center" > 0.9787396< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< tr class = "even" >
< td align = "center" > Streptococcus< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.7318690< / td >
2019-01-02 23:24:07 +01:00
< td align = "center" > 0.0000000< / td >
2019-02-25 16:07:21 +01:00
< td align = "center" > 0.7318690< / td >
2019-01-02 23:24:07 +01:00
< / tr >
< / tbody >
< / table >
< p > To make a transition to the next part, let’ s see how this difference could be plotted:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb29" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb29-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb29-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (genus) < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
< a class = "sourceLine" id = "cb29-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/summarise.html" > summarise< / a > < / span > (< span class = "st" > "1. Amoxicillin"< / span > =< span class = "st" > < / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_S< / a > < / span > (amcl),< / a >
< a class = "sourceLine" id = "cb29-4" title = "4" > < span class = "st" > "2. Gentamicin"< / span > =< span class = "st" > < / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_S< / a > < / span > (gent),< / a >
< a class = "sourceLine" id = "cb29-5" title = "5" > < span class = "st" > "3. Amox + gent"< / span > =< span class = "st" > < / span > < span class = "kw" > < a href = "../reference/portion.html" > portion_S< / a > < / span > (amcl, gent)) < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
< a class = "sourceLine" id = "cb29-6" title = "6" > < span class = "st" > < / span > tidyr< span class = "op" > ::< / span > < span class = "kw" > < a href = "https://tidyr.tidyverse.org/reference/gather.html" > gather< / a > < / span > (< span class = "st" > "Antibiotic"< / span > , < span class = "st" > "S"< / span > , < span class = "op" > -< / span > genus) < span class = "op" > %> %< / span > < / a >
< a class = "sourceLine" id = "cb29-7" title = "7" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/ggplot.html" > ggplot< / a > < / span > (< span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/aes.html" > aes< / a > < / span > (< span class = "dt" > x =< / span > genus,< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb29-8" title = "8" > < span class = "dt" > y =< / span > S,< / a >
< a class = "sourceLine" id = "cb29-9" title = "9" > < span class = "dt" > fill =< / span > Antibiotic)) < span class = "op" > +< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb29-10" title = "10" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/geom_bar.html" > geom_col< / a > < / span > (< span class = "dt" > position =< / span > < span class = "st" > "dodge2"< / span > )< / a > < / code > < / pre > < / div >
< p > < img src = "AMR_files/figure-html/plot%201-1.png" width = "720" > < / p >
2019-01-02 23:24:07 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< div id = "plots" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#plots" class = "anchor" > < / a > Plots< / h2 >
2019-01-02 23:24:07 +01:00
< p > To show results in plots, most R users would nowadays use the < code > ggplot2< / code > package. This package lets you create plots in layers. You can read more about it < a href = "https://ggplot2.tidyverse.org/" > on their website< / a > . A quick example would look like these syntaxes:< / p >
2019-02-20 13:57:23 +01:00
< div class = "sourceCode" id = "cb30" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb30-1" title = "1" > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/ggplot.html" > ggplot< / a > < / span > (< span class = "dt" > data =< / span > a_data_set,< / a >
< a class = "sourceLine" id = "cb30-2" title = "2" > < span class = "dt" > mapping =< / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/aes.html" > aes< / a > < / span > (< span class = "dt" > x =< / span > year,< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb30-3" title = "3" > < span class = "dt" > y =< / span > value)) < span class = "op" > +< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb30-4" title = "4" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/geom_bar.html" > geom_col< / a > < / span > () < span class = "op" > +< / span > < / a >
< a class = "sourceLine" id = "cb30-5" title = "5" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/labs.html" > labs< / a > < / span > (< span class = "dt" > title =< / span > < span class = "st" > "A title"< / span > ,< / a >
< a class = "sourceLine" id = "cb30-6" title = "6" > < span class = "dt" > subtitle =< / span > < span class = "st" > "A subtitle"< / span > ,< / a >
< a class = "sourceLine" id = "cb30-7" title = "7" > < span class = "dt" > x =< / span > < span class = "st" > "My X axis"< / span > ,< / a >
< a class = "sourceLine" id = "cb30-8" title = "8" > < span class = "dt" > y =< / span > < span class = "st" > "My Y axis"< / span > )< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb30-9" title = "9" > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb30-10" title = "10" > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/ggplot.html" > ggplot< / a > < / span > (a_data_set,< / a >
< a class = "sourceLine" id = "cb30-11" title = "11" > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/aes.html" > aes< / a > < / span > (year, value) < span class = "op" > +< / span > < / a >
< a class = "sourceLine" id = "cb30-12" title = "12" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/geom_bar.html" > geom_bar< / a > < / span > ()< / a > < / code > < / pre > < / div >
< p > The < code > AMR< / code > package contains functions to extend this < code > ggplot2< / code > package, for example < code > < a href = "../reference/ggplot_rsi.html" > geom_rsi()< / a > < / code > . It automatically transforms data with < code > < a href = "../reference/count.html" > count_df()< / a > < / code > or < code > < a href = "../reference/portion.html" > portion_df()< / a > < / code > and show results in stacked bars. Its simplest and shortest example:< / p >
< div class = "sourceCode" id = "cb31" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb31-1" title = "1" > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/ggplot.html" > ggplot< / a > < / span > (data_1st) < span class = "op" > +< / span > < / a >
< a class = "sourceLine" id = "cb31-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/ggplot_rsi.html" > geom_rsi< / a > < / span > (< span class = "dt" > translate_ab =< / span > < span class = "ot" > FALSE< / span > )< / a > < / code > < / pre > < / div >
< p > < img src = "AMR_files/figure-html/plot%203-1.png" width = "720" > < / p >
2019-01-02 23:24:07 +01:00
< p > Omit the < code > translate_ab = FALSE< / code > to have the antibiotic codes (amox, amcl, cipr, gent) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin).< / p >
< p > If we group on e.g. the < code > genus< / code > column and add some additional functions from our package, we can create this:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb32" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb32-1" title = "1" > < span class = "co" > # group the data on `genus`< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-2" title = "2" > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/ggplot.html" > ggplot< / a > < / span > (data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (genus)) < span class = "op" > +< / span > < span class = "st" > < / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-3" title = "3" > < span class = "st" > < / span > < span class = "co" > # create bars with genus on x axis< / span > < / a >
< a class = "sourceLine" id = "cb32-4" title = "4" > < span class = "st" > < / span > < span class = "co" > # it looks for variables with class `rsi`,< / span > < / a >
< a class = "sourceLine" id = "cb32-5" title = "5" > < span class = "st" > < / span > < span class = "co" > # of which we have 4 (earlier created with `as.rsi`)< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-6" title = "6" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/ggplot_rsi.html" > geom_rsi< / a > < / span > (< span class = "dt" > x =< / span > < span class = "st" > "genus"< / span > ) < span class = "op" > +< / span > < span class = "st" > < / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-7" title = "7" > < span class = "st" > < / span > < span class = "co" > # split plots on antibiotic< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-8" title = "8" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/ggplot_rsi.html" > facet_rsi< / a > < / span > (< span class = "dt" > facet =< / span > < span class = "st" > "Antibiotic"< / span > ) < span class = "op" > +< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-9" title = "9" > < span class = "st" > < / span > < span class = "co" > # make R red, I yellow and S green< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-10" title = "10" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/ggplot_rsi.html" > scale_rsi_colours< / a > < / span > () < span class = "op" > +< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-11" title = "11" > < span class = "st" > < / span > < span class = "co" > # show percentages on y axis< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-12" title = "12" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/ggplot_rsi.html" > scale_y_percent< / a > < / span > (< span class = "dt" > breaks =< / span > < span class = "dv" > 0< / span > < span class = "op" > :< / span > < span class = "dv" > 4< / span > < span class = "op" > *< / span > < span class = "st" > < / span > < span class = "dv" > 25< / span > ) < span class = "op" > +< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-13" title = "13" > < span class = "st" > < / span > < span class = "co" > # turn 90 degrees, make it bars instead of columns< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-14" title = "14" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/coord_flip.html" > coord_flip< / a > < / span > () < span class = "op" > +< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-15" title = "15" > < span class = "st" > < / span > < span class = "co" > # add labels< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-16" title = "16" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/labs.html" > labs< / a > < / span > (< span class = "dt" > title =< / span > < span class = "st" > "Resistance per genus and antibiotic"< / span > , < / a >
< a class = "sourceLine" id = "cb32-17" title = "17" > < span class = "dt" > subtitle =< / span > < span class = "st" > "(this is fake data)"< / span > ) < span class = "op" > +< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb32-18" title = "18" > < span class = "st" > < / span > < span class = "co" > # and print genus in italic to follow our convention< / span > < / a >
< a class = "sourceLine" id = "cb32-19" title = "19" > < span class = "st" > < / span > < span class = "co" > # (is now y axis because we turned the plot)< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb32-20" title = "20" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/theme.html" > theme< / a > < / span > (< span class = "dt" > axis.text.y =< / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/element.html" > element_text< / a > < / span > (< span class = "dt" > face =< / span > < span class = "st" > "italic"< / span > ))< / a > < / code > < / pre > < / div >
< p > < img src = "AMR_files/figure-html/plot%204-1.png" width = "720" > < / p >
< p > To simplify this, we also created the < code > < a href = "../reference/ggplot_rsi.html" > ggplot_rsi()< / a > < / code > function, which combines almost all above functions:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb33" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb33-1" title = "1" > data_1st < span class = "op" > %> %< / span > < span class = "st" > < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb33-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (genus) < span class = "op" > %> %< / span > < / a >
< a class = "sourceLine" id = "cb33-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/ggplot_rsi.html" > ggplot_rsi< / a > < / span > (< span class = "dt" > x =< / span > < span class = "st" > "genus"< / span > ,< / a >
< a class = "sourceLine" id = "cb33-4" title = "4" > < span class = "dt" > facet =< / span > < span class = "st" > "Antibiotic"< / span > ,< / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb33-5" title = "5" > < span class = "dt" > breaks =< / span > < span class = "dv" > 0< / span > < span class = "op" > :< / span > < span class = "dv" > 4< / span > < span class = "op" > *< / span > < span class = "st" > < / span > < span class = "dv" > 25< / span > ,< / a >
< a class = "sourceLine" id = "cb33-6" title = "6" > < span class = "dt" > datalabels =< / span > < span class = "ot" > FALSE< / span > ) < span class = "op" > +< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb33-7" title = "7" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://ggplot2.tidyverse.org/reference/coord_flip.html" > coord_flip< / a > < / span > ()< / a > < / code > < / pre > < / div >
< p > < img src = "AMR_files/figure-html/plot%205-1.png" width = "720" > < / p >
2019-01-02 23:24:07 +01:00
< / div >
2019-02-01 16:55:55 +01:00
< div id = "independence-test" class = "section level2" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#independence-test" class = "anchor" > < / a > Independence test< / h2 >
2019-01-02 23:24:07 +01:00
< p > The next example uses the included < code > septic_patients< / code > , which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This < code > data.frame< / code > can be used to practice AMR analysis.< / p >
2019-02-20 13:57:23 +01:00
< p > We will compare the resistance to fosfomycin (column < code > fosf< / code > ) in hospital A and D. The input for the final < code > < a href = "https://www.rdocumentation.org/packages/stats/topics/fisher.test" > fisher.test()< / a > < / code > will be this:< / p >
< table class = "table" >
< thead > < tr class = "header" >
2019-01-02 23:24:07 +01:00
< th > < / th >
< th align = "left" > A< / th >
< th align = "left" > D< / th >
2019-02-20 13:57:23 +01:00
< / tr > < / thead >
2019-01-02 23:24:07 +01:00
< tbody >
< tr class = "odd" >
< td > IR< / td >
< td align = "left" > 24< / td >
< td align = "left" > 33< / td >
< / tr >
< tr class = "even" >
< td > S< / td >
< td align = "left" > 25< / td >
< td align = "left" > 77< / td >
< / tr >
< / tbody >
< / table >
< p > We can transform the data and apply the test in only a couple of lines:< / p >
2019-02-11 10:27:10 +01:00
< div class = "sourceCode" id = "cb34" > < pre class = "sourceCode r" > < code class = "sourceCode r" > < a class = "sourceLine" id = "cb34-1" title = "1" > septic_patients < span class = "op" > %> %< / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb34-2" title = "2" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/filter.html" > filter< / a > < / span > (hospital_id < span class = "op" > %in%< / span > < span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/c" > c< / a > < / span > (< span class = "st" > "A"< / span > , < span class = "st" > "D"< / span > )) < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # filter on only hospitals A and D< / span > < / a >
< a class = "sourceLine" id = "cb34-3" title = "3" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/select.html" > select< / a > < / span > (hospital_id, fosf) < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # select the hospitals and fosfomycin< / span > < / a >
< a class = "sourceLine" id = "cb34-4" title = "4" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/group_by.html" > group_by< / a > < / span > (hospital_id) < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # group on the hospitals< / span > < / a >
< a class = "sourceLine" id = "cb34-5" title = "5" > < span class = "st" > < / span > < span class = "kw" > < a href = "../reference/count.html" > count_df< / a > < / span > (< span class = "dt" > combine_IR =< / span > < span class = "ot" > TRUE< / span > ) < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # count all isolates per group (hospital_id)< / span > < / a >
< a class = "sourceLine" id = "cb34-6" title = "6" > < span class = "st" > < / span > tidyr< span class = "op" > ::< / span > < span class = "kw" > < a href = "https://tidyr.tidyverse.org/reference/spread.html" > spread< / a > < / span > (hospital_id, Value) < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # transform output so A and D are columns< / span > < / a >
< a class = "sourceLine" id = "cb34-7" title = "7" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://dplyr.tidyverse.org/reference/select.html" > select< / a > < / span > (A, D) < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # and select these only< / span > < / a >
< a class = "sourceLine" id = "cb34-8" title = "8" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/base/topics/matrix" > as.matrix< / a > < / span > () < span class = "op" > %> %< / span > < span class = "st" > < / span > < span class = "co" > # transform to good old matrix for fisher.test()< / span > < / a >
< a class = "sourceLine" id = "cb34-9" title = "9" > < span class = "st" > < / span > < span class = "kw" > < a href = "https://www.rdocumentation.org/packages/stats/topics/fisher.test" > fisher.test< / a > < / span > () < span class = "co" > # do Fisher's Exact Test< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb34-10" title = "10" > < span class = "co" > #> < / span > < / a >
2019-02-20 13:57:23 +01:00
< a class = "sourceLine" id = "cb34-11" title = "11" > < span class = "co" > #> Fisher's Exact Test for Count Data< / span > < / a >
2019-02-11 10:27:10 +01:00
< a class = "sourceLine" id = "cb34-12" title = "12" > < span class = "co" > #> < / span > < / a >
< a class = "sourceLine" id = "cb34-13" title = "13" > < span class = "co" > #> data: .< / span > < / a >
< a class = "sourceLine" id = "cb34-14" title = "14" > < span class = "co" > #> p-value = 0.03104< / span > < / a >
< a class = "sourceLine" id = "cb34-15" title = "15" > < span class = "co" > #> alternative hypothesis: true odds ratio is not equal to 1< / span > < / a >
< a class = "sourceLine" id = "cb34-16" title = "16" > < span class = "co" > #> 95 percent confidence interval:< / span > < / a >
< a class = "sourceLine" id = "cb34-17" title = "17" > < span class = "co" > #> 1.054283 4.735995< / span > < / a >
< a class = "sourceLine" id = "cb34-18" title = "18" > < span class = "co" > #> sample estimates:< / span > < / a >
< a class = "sourceLine" id = "cb34-19" title = "19" > < span class = "co" > #> odds ratio < / span > < / a >
< a class = "sourceLine" id = "cb34-20" title = "20" > < span class = "co" > #> 2.228006< / span > < / a > < / code > < / pre > < / div >
2019-01-02 23:24:07 +01:00
< p > As can be seen, the p value is 0.03, which means that the fosfomycin resistances found in hospital A and D are really different.< / p >
2018-12-31 01:48:53 +01:00
< / div >
< / div >
2018-12-29 22:24:19 +01:00
< / div >
< div class = "col-md-3 hidden-xs hidden-sm" id = "sidebar" >
2018-12-31 01:48:53 +01:00
< div id = "tocnav" >
2019-02-20 13:57:23 +01:00
< h2 class = "hasAnchor" >
< a href = "#tocnav" class = "anchor" > < / a > Contents< / h2 >
< ul class = "nav nav-pills nav-stacked" >
< li >
< a href = "#introduction" > Introduction< / a > < ul class = "nav nav-pills nav-stacked" >
< li > < a href = "#needed-r-packages" > Needed R packages< / a > < / li >
< / ul >
< / li >
< li >
< a href = "#creation-of-data" > Creation of data< / a > < ul class = "nav nav-pills nav-stacked" >
< li > < a href = "#patients" > Patients< / a > < / li >
2019-02-01 16:55:55 +01:00
< li > < a href = "#dates" > Dates< / a > < / li >
< li > < a href = "#other-variables" > Other variables< / a > < / li >
< li > < a href = "#put-everything-together" > Put everything together< / a > < / li >
2019-02-20 13:57:23 +01:00
< / ul >
< / li >
2018-12-31 01:48:53 +01:00
< li > < a href = "#cleaning-the-data" > Cleaning the data< / a > < / li >
2019-02-20 13:57:23 +01:00
< li >
< a href = "#adding-new-variables" > Adding new variables< / a > < ul class = "nav nav-pills nav-stacked" >
< li > < a href = "#first-isolates" > First isolates< / a > < / li >
2019-02-01 16:55:55 +01:00
< li > < a href = "#first-weighted-isolates" > First < em > weighted< / em > isolates< / a > < / li >
2019-02-20 13:57:23 +01:00
< / ul >
< / li >
< li >
< a href = "#analysing-the-data" > Analysing the data< / a > < ul class = "nav nav-pills nav-stacked" >
< li > < a href = "#dispersion-of-species" > Dispersion of species< / a > < / li >
2019-02-01 16:55:55 +01:00
< li > < a href = "#resistance-percentages" > Resistance percentages< / a > < / li >
< li > < a href = "#plots" > Plots< / a > < / li >
< li > < a href = "#independence-test" > Independence test< / a > < / li >
< / ul >
2019-02-20 13:57:23 +01:00
< / li >
< / ul >
< / div >
2018-12-29 22:24:19 +01:00
< / div >
< / div >
2019-02-20 13:57:23 +01:00
< footer > < div class = "copyright" >
< p > Developed by < a href = "https://www.rug.nl/staff/m.s.berends/" > Matthijs S. Berends< / a > , < a href = "https://www.rug.nl/staff/c.f.luz/" > Christian F. Luz< / a > , < a href = "https://www.rug.nl/staff/c.glasner/" > Corinna Glasner< / a > , < a href = "https://www.rug.nl/staff/a.w.friedrich/" > Alex W. Friedrich< / a > , < a href = "https://www.rug.nl/staff/b.sinha/" > Bhanu N. M. Sinha< / a > .< / p >
2018-12-29 22:24:19 +01:00
< / div >
< div class = "pkgdown" >
< p > Site built with < a href = "https://pkgdown.r-lib.org/" > pkgdown< / a > 1.3.0.< / p >
< / div >
< / footer >
2019-02-20 13:57:23 +01:00
< / div >
2018-12-29 22:24:19 +01:00
2019-02-20 13:57:23 +01:00
< script src = "https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.js" integrity = "sha256-GKvGqXDznoRYHCwKXGnuchvKSwmx9SRMrZOTh2g4Sb0=" crossorigin = "anonymous" > < / script > < script >
2018-12-29 22:24:19 +01:00
docsearch({
apiKey: 'f737050abfd4d726c63938e18f8c496e',
indexName: 'amr',
inputSelector: 'input#search-input.form-control',
transformData: function(hits) {
return hits.map(function (hit) {
hit.url = updateHitURL(hit);
return hit;
});
}
});
< / script >
2019-02-20 13:57:23 +01:00
< / body >
2018-12-29 22:24:19 +01:00
< / html >