mirror of
https://github.com/msberends/AMR.git
synced 2025-09-06 04:09:39 +02:00
(v2.1.1.9186) replace antibiotics
with antimicrobials
!
This commit is contained in:
@@ -27,51 +27,53 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
resistance_data <- structure(
|
||||
list(
|
||||
order = c("Bacillales", "Enterobacterales", "Enterobacterales"),
|
||||
genus = c("Staphylococcus", "Escherichia", "Klebsiella"),
|
||||
AMC = c(0.00425, 0.13062, 0.10344),
|
||||
CXM = c(0.00425, 0.05376, 0.10344),
|
||||
CTX = c(0.00000, 0.02396, 0.05172),
|
||||
TOB = c(0.02325, 0.02597, 0.10344),
|
||||
TMP = c(0.08387, 0.39141, 0.18367)
|
||||
),
|
||||
class = c("grouped_df", "tbl_df", "tbl", "data.frame"),
|
||||
row.names = c(NA, -3L),
|
||||
groups = structure(
|
||||
test_that("pca works", {
|
||||
resistance_data <- structure(
|
||||
list(
|
||||
order = c("Bacillales", "Enterobacterales"),
|
||||
.rows = list(1L, 2:3)
|
||||
order = c("Bacillales", "Enterobacterales", "Enterobacterales"),
|
||||
genus = c("Staphylococcus", "Escherichia", "Klebsiella"),
|
||||
AMC = c(0.00425, 0.13062, 0.10344),
|
||||
CXM = c(0.00425, 0.05376, 0.10344),
|
||||
CTX = c(0.00000, 0.02396, 0.05172),
|
||||
TOB = c(0.02325, 0.02597, 0.10344),
|
||||
TMP = c(0.08387, 0.39141, 0.18367)
|
||||
),
|
||||
row.names = c(NA, -2L),
|
||||
class = c("tbl_df", "tbl", "data.frame"),
|
||||
.drop = TRUE
|
||||
class = c("grouped_df", "tbl_df", "tbl", "data.frame"),
|
||||
row.names = c(NA, -3L),
|
||||
groups = structure(
|
||||
list(
|
||||
order = c("Bacillales", "Enterobacterales"),
|
||||
.rows = list(1L, 2:3)
|
||||
),
|
||||
row.names = c(NA, -2L),
|
||||
class = c("tbl_df", "tbl", "data.frame"),
|
||||
.drop = TRUE
|
||||
)
|
||||
)
|
||||
)
|
||||
pca_model <- pca(resistance_data)
|
||||
expect_inherits(pca_model, "pca")
|
||||
pca_model <- pca(resistance_data)
|
||||
expect_inherits(pca_model, "pca")
|
||||
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
|
||||
if (AMR:::pkg_is_available("ggplot2")) {
|
||||
ggplot_pca(pca_model, ellipse = TRUE)
|
||||
ggplot_pca(pca_model, arrows_textangled = FALSE)
|
||||
}
|
||||
|
||||
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) {
|
||||
resistance_data <- example_isolates %>%
|
||||
group_by(
|
||||
order = mo_order(mo),
|
||||
genus = mo_genus(mo)
|
||||
) %>%
|
||||
summarise_if(is.sir, resistance, minimum = 0)
|
||||
pca_result <- resistance_data %>%
|
||||
pca(AMC, CXM, CTX, CAZ, GEN, TOB, TMP, "SXT")
|
||||
expect_inherits(pca_result, "prcomp")
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
|
||||
if (AMR:::pkg_is_available("ggplot2")) {
|
||||
ggplot_pca(pca_result, ellipse = TRUE)
|
||||
ggplot_pca(pca_result, ellipse = FALSE, arrows_textangled = FALSE, scale = FALSE)
|
||||
ggplot_pca(pca_model, ellipse = TRUE)
|
||||
ggplot_pca(pca_model, arrows_textangled = FALSE)
|
||||
}
|
||||
}
|
||||
|
||||
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) {
|
||||
resistance_data <- example_isolates %>%
|
||||
group_by(
|
||||
order = mo_order(mo),
|
||||
genus = mo_genus(mo)
|
||||
) %>%
|
||||
summarise_if(is.sir, resistance, minimum = 0)
|
||||
pca_result <- resistance_data %>%
|
||||
pca(AMC, CXM, CTX, CAZ, GEN, TOB, TMP, "SXT")
|
||||
expect_inherits(pca_result, "prcomp")
|
||||
|
||||
if (AMR:::pkg_is_available("ggplot2")) {
|
||||
ggplot_pca(pca_result, ellipse = TRUE)
|
||||
ggplot_pca(pca_result, ellipse = FALSE, arrows_textangled = FALSE, scale = FALSE)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user