mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 20:06:12 +01:00
(v0.6.1.9047) ggplot fix
This commit is contained in:
parent
4ed27c7e7a
commit
0a6580b4eb
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@ vignettes/*.R
|
||||
^CRAN-RELEASE$
|
||||
packrat/lib*/
|
||||
packrat/src/
|
||||
cran-comments.md
|
||||
|
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 0.6.1.9046
|
||||
Version: 0.6.1.9047
|
||||
Date: 2019-05-31
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
|
41
R/zzz.R
41
R/zzz.R
@ -29,10 +29,6 @@
|
||||
microorganisms.oldDT$fullname_lower <- tolower(microorganisms.oldDT$fullname)
|
||||
setkey(microorganisms.oldDT, col_id, fullname)
|
||||
|
||||
assign(x = "microorganisms",
|
||||
value = make(),
|
||||
envir = asNamespace("AMR"))
|
||||
|
||||
assign(x = "microorganismsDT",
|
||||
value = make_DT(),
|
||||
envir = asNamespace("AMR"))
|
||||
@ -55,44 +51,9 @@
|
||||
|
||||
}
|
||||
|
||||
#' @importFrom dplyr mutate case_when
|
||||
make <- function() {
|
||||
AMR::microorganisms %>%
|
||||
mutate(prevalence = case_when(
|
||||
class == "Gammaproteobacteria"
|
||||
| genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus")
|
||||
| mo == "UNKNOWN"
|
||||
~ 1,
|
||||
phylum %in% c("Proteobacteria",
|
||||
"Firmicutes",
|
||||
"Actinobacteria",
|
||||
"Sarcomastigophora")
|
||||
| genus %in% c("Aspergillus",
|
||||
"Bacteroides",
|
||||
"Candida",
|
||||
"Capnocytophaga",
|
||||
"Chryseobacterium",
|
||||
"Cryptococcus",
|
||||
"Elisabethkingia",
|
||||
"Flavobacterium",
|
||||
"Fusobacterium",
|
||||
"Giardia",
|
||||
"Leptotrichia",
|
||||
"Mycoplasma",
|
||||
"Prevotella",
|
||||
"Rhodotorula",
|
||||
"Treponema",
|
||||
"Trichophyton",
|
||||
"Ureaplasma")
|
||||
| rank %in% c("kingdom", "phylum", "class", "order", "family")
|
||||
~ 2,
|
||||
TRUE ~ 3
|
||||
))
|
||||
}
|
||||
|
||||
#' @importFrom data.table as.data.table setkey
|
||||
make_DT <- function() {
|
||||
microorganismsDT <- as.data.table(make())
|
||||
microorganismsDT <- as.data.table(AMR::microorganisms)
|
||||
microorganismsDT$fullname_lower <- tolower(microorganismsDT$fullname)
|
||||
setkey(microorganismsDT,
|
||||
prevalence,
|
||||
|
Binary file not shown.
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -485,7 +485,7 @@
|
||||
<span class='kw'>nrow</span> <span class='kw'>=</span> <span class='fl'>1</span>,
|
||||
<span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"AMR of Top Three Microorganisms In Blood Culture Isolates"</span>,
|
||||
<span class='kw'>subtitle</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/expression'>expression</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/paste'>paste</a></span>(<span class='st'>"Only First Isolates, CoNS grouped according to Becker "</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/grDevices/topics/plotmath'>italic</a></span>(<span class='st'>"et al."</span>), <span class='st'>" (2014)"</span>)),
|
||||
<span class='kw'>x.title</span> <span class='kw'>=</span> <span class='st'>"Antibiotic (Ears-Net code)"</span>)
|
||||
<span class='kw'>x.title</span> <span class='kw'>=</span> <span class='st'>"Antibiotic (EARS-Net code)"</span>)
|
||||
<span class='co'># }</span></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
|
@ -78,7 +78,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9047</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -452,6 +452,39 @@ MOs <- MOs %>%
|
||||
sum(duplicated(MOs$mo))
|
||||
colnames(MOs)
|
||||
|
||||
# set prevalence per species
|
||||
MOs <- MOs %>%
|
||||
mutate(prevalence = case_when(
|
||||
class == "Gammaproteobacteria"
|
||||
| genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus")
|
||||
| mo == "UNKNOWN"
|
||||
~ 1,
|
||||
phylum %in% c("Proteobacteria",
|
||||
"Firmicutes",
|
||||
"Actinobacteria",
|
||||
"Sarcomastigophora")
|
||||
| genus %in% c("Aspergillus",
|
||||
"Bacteroides",
|
||||
"Candida",
|
||||
"Capnocytophaga",
|
||||
"Chryseobacterium",
|
||||
"Cryptococcus",
|
||||
"Elisabethkingia",
|
||||
"Flavobacterium",
|
||||
"Fusobacterium",
|
||||
"Giardia",
|
||||
"Leptotrichia",
|
||||
"Mycoplasma",
|
||||
"Prevotella",
|
||||
"Rhodotorula",
|
||||
"Treponema",
|
||||
"Trichophyton",
|
||||
"Ureaplasma")
|
||||
| rank %in% c("kingdom", "phylum", "class", "order", "family")
|
||||
~ 2,
|
||||
TRUE ~ 3
|
||||
))
|
||||
|
||||
# save it
|
||||
MOs <- as.data.frame(MOs %>% arrange(fullname), stringsAsFactors = FALSE)
|
||||
MOs.old <- as.data.frame(MOs.old, stringsAsFactors = FALSE)
|
||||
|
@ -59,9 +59,6 @@ test_that("ggplot_rsi works", {
|
||||
summarise_all(count_IR) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(colnames(getlbls(septic_patients %>% select(AMC, CIP))),
|
||||
c("Interpretation", "Antibiotic", "Value", "lbl"))
|
||||
|
||||
expect_error(ggplot_rsi(septic_patients, fun = "invalid"))
|
||||
expect_error(geom_rsi(septic_patients, fun = "invalid"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user