2020-03-08 09:12:11 +01:00
|
|
|
# ==================================================================== #
|
|
|
|
# TITLE #
|
2020-10-08 11:16:03 +02:00
|
|
|
# Antimicrobial Resistance (AMR) Analysis for R #
|
2020-03-08 09:12:11 +01:00
|
|
|
# #
|
|
|
|
# SOURCE #
|
2020-07-08 14:48:06 +02:00
|
|
|
# https://github.com/msberends/AMR #
|
2020-03-08 09:12:11 +01:00
|
|
|
# #
|
|
|
|
# LICENCE #
|
|
|
|
# (c) 2018-2020 Berends MS, Luz CF et al. #
|
2020-10-08 11:16:03 +02:00
|
|
|
# Developed at the University of Groningen, the Netherlands, in #
|
|
|
|
# collaboration with non-profit organisations Certe Medical #
|
|
|
|
# Diagnostics & Advice, and University Medical Center Groningen. #
|
2020-03-08 09:12:11 +01:00
|
|
|
# #
|
|
|
|
# This R package is free software; you can freely use and distribute #
|
|
|
|
# it for both personal and commercial purposes under the terms of the #
|
|
|
|
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
|
|
|
# the Free Software Foundation. #
|
|
|
|
# We created this package for both routine data analysis and academic #
|
|
|
|
# research and it was publicly released in the hope that it will be #
|
|
|
|
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
2020-10-08 11:16:03 +02:00
|
|
|
# #
|
|
|
|
# Visit our website for the full manual and a complete tutorial about #
|
|
|
|
# how to conduct AMR analysis: https://msberends.github.io/AMR/ #
|
2020-03-08 09:12:11 +01:00
|
|
|
# ==================================================================== #
|
|
|
|
|
|
|
|
context("pca.R")
|
|
|
|
|
|
|
|
test_that("PCA works", {
|
2020-07-30 15:15:52 +02:00
|
|
|
|
|
|
|
skip_on_cran()
|
|
|
|
|
2020-05-16 13:05:47 +02:00
|
|
|
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(list(order = c("Bacillales", "Enterobacterales"),
|
|
|
|
.rows = list(1L, 2:3)),
|
|
|
|
row.names = c(NA, -2L),
|
|
|
|
class = c("tbl_df", "tbl", "data.frame"),
|
|
|
|
.drop = TRUE))
|
2020-03-08 09:12:11 +01:00
|
|
|
|
2020-03-08 11:18:59 +01:00
|
|
|
pca_model <- pca(resistance_data)
|
2020-03-08 09:12:11 +01:00
|
|
|
|
2020-03-08 11:18:59 +01:00
|
|
|
expect_s3_class(pca_model, "pca")
|
|
|
|
|
2020-09-25 14:44:50 +02:00
|
|
|
pdf(NULL) # prevent Rplots.pdf being created
|
|
|
|
|
2020-03-08 11:18:59 +01:00
|
|
|
ggplot_pca(pca_model, ellipse = TRUE)
|
2020-07-28 18:39:57 +02:00
|
|
|
ggplot_pca(pca_model, arrows_textangled = FALSE)
|
2020-03-08 09:12:11 +01:00
|
|
|
})
|