1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 21:26:12 +01:00

add XPT files for SAS software

This commit is contained in:
dr. M.S. (Matthijs) Berends 2023-05-12 10:07:55 +02:00
parent 91fa73dedf
commit 8179092c57
11 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 2.0.0.9015 Version: 2.0.0.9015
Date: 2023-05-11 Date: 2023-05-12
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by data analysis and to work with microbial and antimicrobial properties by

View File

@ -10,6 +10,8 @@
* Added microbial codes for Gram-negative/positive anaerobic bacteria * Added microbial codes for Gram-negative/positive anaerobic bacteria
* `mo_rank()` now returns `NA` for 'unknown' microorganisms (`B_ANAER`, `B_ANAER-NEG`, `B_ANAER-POS`, `B_GRAMN`, `B_GRAMP`, `F_FUNGUS`, `F_YEAST`, and `UNKNOWN`) * `mo_rank()` now returns `NA` for 'unknown' microorganisms (`B_ANAER`, `B_ANAER-NEG`, `B_ANAER-POS`, `B_GRAMN`, `B_GRAMP`, `F_FUNGUS`, `F_YEAST`, and `UNKNOWN`)
* Fixed a bug for `as.mo()` that led to coercion of `NA` values when using custom microorganism codes * Fixed a bug for `as.mo()` that led to coercion of `NA` values when using custom microorganism codes
* Added SAS Transport files (file extension `.xpt`) to [our download page](https://msberends.github.io/AMR/articles/datasets.html) to use in SAS software
# AMR 2.0.0 # AMR 2.0.0

View File

@ -366,7 +366,7 @@ if (changed_md5(clin_break)) {
write_md5(clin_break) write_md5(clin_break)
try(saveRDS(clin_break, "data-raw/clinical_breakpoints.rds", version = 2, compress = "xz"), silent = TRUE) try(saveRDS(clin_break, "data-raw/clinical_breakpoints.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(clin_break, "data-raw/clinical_breakpoints.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE) try(write.table(clin_break, "data-raw/clinical_breakpoints.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_sas(clin_break, "data-raw/clinical_breakpoints.sas"), silent = TRUE) try(haven::write_xpt(clin_break, "data-raw/clinical_breakpoints.xpt"), silent = TRUE)
try(haven::write_sav(clin_break, "data-raw/clinical_breakpoints.sav"), silent = TRUE) try(haven::write_sav(clin_break, "data-raw/clinical_breakpoints.sav"), silent = TRUE)
try(haven::write_dta(clin_break, "data-raw/clinical_breakpoints.dta"), silent = TRUE) try(haven::write_dta(clin_break, "data-raw/clinical_breakpoints.dta"), silent = TRUE)
try(openxlsx::write.xlsx(clin_break, "data-raw/clinical_breakpoints.xlsx"), silent = TRUE) try(openxlsx::write.xlsx(clin_break, "data-raw/clinical_breakpoints.xlsx"), silent = TRUE)
@ -382,7 +382,7 @@ if (changed_md5(microorganisms)) {
mo <- microorganisms mo <- microorganisms
mo$snomed <- max_50_snomed mo$snomed <- max_50_snomed
mo <- dplyr::mutate_if(mo, ~ !is.numeric(.), as.character) mo <- dplyr::mutate_if(mo, ~ !is.numeric(.), as.character)
try(haven::write_sas(mo, "data-raw/microorganisms.sas"), silent = TRUE) try(haven::write_xpt(mo, "data-raw/microorganisms.xpt"), silent = TRUE)
try(haven::write_sav(mo, "data-raw/microorganisms.sav"), silent = TRUE) try(haven::write_sav(mo, "data-raw/microorganisms.sav"), silent = TRUE)
try(haven::write_dta(mo, "data-raw/microorganisms.dta"), silent = TRUE) try(haven::write_dta(mo, "data-raw/microorganisms.dta"), silent = TRUE)
mo_all_snomed <- microorganisms %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ",")) mo_all_snomed <- microorganisms %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ","))
@ -397,7 +397,7 @@ if (changed_md5(ab)) {
usethis::ui_info(paste0("Saving {usethis::ui_value('antibiotics')} to {usethis::ui_value('data-raw/')}")) usethis::ui_info(paste0("Saving {usethis::ui_value('antibiotics')} to {usethis::ui_value('data-raw/')}"))
write_md5(ab) write_md5(ab)
try(saveRDS(antibiotics, "data-raw/antibiotics.rds", version = 2, compress = "xz"), silent = TRUE) try(saveRDS(antibiotics, "data-raw/antibiotics.rds", version = 2, compress = "xz"), silent = TRUE)
try(haven::write_sas(ab, "data-raw/antibiotics.sas"), silent = TRUE) try(haven::write_xpt(ab, "data-raw/antibiotics.xpt"), silent = TRUE)
try(haven::write_sav(ab, "data-raw/antibiotics.sav"), silent = TRUE) try(haven::write_sav(ab, "data-raw/antibiotics.sav"), silent = TRUE)
try(haven::write_dta(ab, "data-raw/antibiotics.dta"), silent = TRUE) try(haven::write_dta(ab, "data-raw/antibiotics.dta"), silent = TRUE)
ab_lists <- antibiotics %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ",")) ab_lists <- antibiotics %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ","))
@ -412,7 +412,7 @@ if (changed_md5(av)) {
usethis::ui_info(paste0("Saving {usethis::ui_value('antivirals')} to {usethis::ui_value('data-raw/')}")) usethis::ui_info(paste0("Saving {usethis::ui_value('antivirals')} to {usethis::ui_value('data-raw/')}"))
write_md5(av) write_md5(av)
try(saveRDS(antivirals, "data-raw/antivirals.rds", version = 2, compress = "xz"), silent = TRUE) try(saveRDS(antivirals, "data-raw/antivirals.rds", version = 2, compress = "xz"), silent = TRUE)
try(haven::write_sas(av, "data-raw/antivirals.sas"), silent = TRUE) try(haven::write_xpt(av, "data-raw/antivirals.xpt"), silent = TRUE)
try(haven::write_sav(av, "data-raw/antivirals.sav"), silent = TRUE) try(haven::write_sav(av, "data-raw/antivirals.sav"), silent = TRUE)
try(haven::write_dta(av, "data-raw/antivirals.dta"), silent = TRUE) try(haven::write_dta(av, "data-raw/antivirals.dta"), silent = TRUE)
av_lists <- antivirals %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ",")) av_lists <- antivirals %>% mutate_if(is.list, function(x) sapply(x, paste, collapse = ","))
@ -433,7 +433,7 @@ if (changed_md5(intrinsicR)) {
write_md5(intrinsicR) write_md5(intrinsicR)
try(saveRDS(intrinsicR, "data-raw/intrinsic_resistant.rds", version = 2, compress = "xz"), silent = TRUE) try(saveRDS(intrinsicR, "data-raw/intrinsic_resistant.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(intrinsicR, "data-raw/intrinsic_resistant.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE) try(write.table(intrinsicR, "data-raw/intrinsic_resistant.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_sas(intrinsicR, "data-raw/intrinsic_resistant.sas"), silent = TRUE) try(haven::write_xpt(intrinsicR, "data-raw/intrinsic_resistant.xpt"), silent = TRUE)
try(haven::write_sav(intrinsicR, "data-raw/intrinsic_resistant.sav"), silent = TRUE) try(haven::write_sav(intrinsicR, "data-raw/intrinsic_resistant.sav"), silent = TRUE)
try(haven::write_dta(intrinsicR, "data-raw/intrinsic_resistant.dta"), silent = TRUE) try(haven::write_dta(intrinsicR, "data-raw/intrinsic_resistant.dta"), silent = TRUE)
try(openxlsx::write.xlsx(intrinsicR, "data-raw/intrinsic_resistant.xlsx"), silent = TRUE) try(openxlsx::write.xlsx(intrinsicR, "data-raw/intrinsic_resistant.xlsx"), silent = TRUE)
@ -446,7 +446,7 @@ if (changed_md5(dosage)) {
write_md5(dosage) write_md5(dosage)
try(saveRDS(dosage, "data-raw/dosage.rds", version = 2, compress = "xz"), silent = TRUE) try(saveRDS(dosage, "data-raw/dosage.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(dosage, "data-raw/dosage.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE) try(write.table(dosage, "data-raw/dosage.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_sas(dosage, "data-raw/dosage.sas"), silent = TRUE) try(haven::write_xpt(dosage, "data-raw/dosage.xpt"), silent = TRUE)
try(haven::write_sav(dosage, "data-raw/dosage.sav"), silent = TRUE) try(haven::write_sav(dosage, "data-raw/dosage.sav"), silent = TRUE)
try(haven::write_dta(dosage, "data-raw/dosage.dta"), silent = TRUE) try(haven::write_dta(dosage, "data-raw/dosage.dta"), silent = TRUE)
try(openxlsx::write.xlsx(dosage, "data-raw/dosage.xlsx"), silent = TRUE) try(openxlsx::write.xlsx(dosage, "data-raw/dosage.xlsx"), silent = TRUE)

BIN
data-raw/antibiotics.xpt Normal file

Binary file not shown.

BIN
data-raw/antivirals.xpt Normal file

Binary file not shown.

Binary file not shown.

BIN
data-raw/dosage.xpt Normal file

Binary file not shown.

Binary file not shown.

BIN
data-raw/microorganisms.xpt Normal file

Binary file not shown.

View File

@ -96,10 +96,9 @@ expect_true(length(mo_synonyms("Candida albicans")) > 1)
expect_inherits(mo_synonyms(c("Candida albicans", "Escherichia coli")), "list") expect_inherits(mo_synonyms(c("Candida albicans", "Escherichia coli")), "list")
expect_equal(names(mo_info("Escherichia coli")), c( expect_equal(names(mo_info("Escherichia coli")), c(
"mo", "mo",
"kingdom", "phylum", "class", "order", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies",
"family", "genus", "species", "subspecies",
"status", "synonyms", "gramstain", "oxygen_tolerance", "status", "synonyms", "gramstain", "oxygen_tolerance",
"url", "ref", "snomed" "url", "ref", "snomed", "lpsn", "gbif"
)) ))
expect_inherits(mo_info(c("Escherichia coli", "Staphylococcus aureus")), "list") expect_inherits(mo_info(c("Escherichia coli", "Staphylococcus aureus")), "list")

View File

@ -50,6 +50,7 @@ download_txt <- function(filename) {
feather <- paste0(filename, ".feather") feather <- paste0(filename, ".feather")
parquet <- paste0(filename, ".parquet") parquet <- paste0(filename, ".parquet")
sas <- paste0(filename, ".sas") sas <- paste0(filename, ".sas")
xpt <- paste0(filename, ".xpt")
spss <- paste0(filename, ".sav") spss <- paste0(filename, ".sav")
stata <- paste0(filename, ".dta") stata <- paste0(filename, ".dta")
create_txt <- function(filename, type, software, exists) { create_txt <- function(filename, type, software, exists) {
@ -70,6 +71,7 @@ download_txt <- function(filename) {
file.exists(feather), file.exists(feather),
file.exists(parquet), file.exists(parquet),
file.exists(sas), file.exists(sas),
file.exists(xpt),
file.exists(spss), file.exists(spss),
file.exists(stata) file.exists(stata)
)) { )) {
@ -80,7 +82,8 @@ download_txt <- function(filename) {
create_txt(excel, "xlsx", "Microsoft Excel workbook", file.exists(excel)), create_txt(excel, "xlsx", "Microsoft Excel workbook", file.exists(excel)),
create_txt(feather, "feather", "Apache Feather file", file.exists(feather)), create_txt(feather, "feather", "Apache Feather file", file.exists(feather)),
create_txt(parquet, "parquet", "Apache Parquet file", file.exists(parquet)), create_txt(parquet, "parquet", "Apache Parquet file", file.exists(parquet)),
create_txt(sas, "sas", "SAS data file", file.exists(sas)), create_txt(sas, "sas", "SAS data (SAS) file", file.exists(sas)),
create_txt(xpt, "xpt", "SAS transport (XPT) file", file.exists(xpt)),
create_txt(spss, "sav", "IBM SPSS Statistics data file", file.exists(spss)), create_txt(spss, "sav", "IBM SPSS Statistics data file", file.exists(spss)),
create_txt(stata, "dta", "Stata DTA file", file.exists(stata)) create_txt(stata, "dta", "Stata DTA file", file.exists(stata))
) )
@ -123,7 +126,7 @@ This data set is in R available as `microorganisms`, after you load the `AMR` pa
`r download_txt("microorganisms")` `r download_txt("microorganisms")`
**NOTE: The exported files for SAS, SPSS and Stata contain only the first 50 SNOMED codes per record, as their file size would otherwise exceed 100 MB; the file size limit of GitHub.** Advice? Use R instead. **NOTE: The exported files for SAS, SPSS and Stata contain only the first 50 SNOMED codes per record, as their file size would otherwise exceed 100 MB; the file size limit of GitHub.** Their file structures and compression techniques are very inefficient. Advice? Use R instead. It's free and much better in many ways.
The tab-separated text file and Microsoft Excel workbook both contain all SNOMED codes as comma separated values. The tab-separated text file and Microsoft Excel workbook both contain all SNOMED codes as comma separated values.