vignettes/ddiwas_r_package_tutorial.Rmd
ddiwas_r_package_tutorial.Rmd
CSV files in this tutorial come from the vignette on how to extract EHR data for DDIWAS.
ehr_drug_allergies <- read_csv("ddi_adr_data.csv", col_types = cols())
names(ehr_drug_allergies) <- tolower(names(ehr_drug_allergies))
drug_allergies <- ddiwas::map_drug_allergies(ehr_drug_allergies = ehr_drug_allergies)
Example input ddi_adr_data.csv
dataframe
Example output drug_allergies
dataframe
df_drug_exposures <- read_csv("ddi_drug_exposures.csv", col_types = cols())
names(df_drug_exposures) <- c("person_id", "concept_id")
covariates <- read_csv("ddi_covariates.csv", col_types = cols())
names(covariates) <- tolower(names(covariates))
covariates <- ddiwas::process_covariates(covariates, df_drug_exposures)
Example input dataframes
ddi_drug_exposures.csv
ddi_covariates.csv
Example output covariates
dataframe
covariates <- ddiwas::require_drug_allergies(ehr_drug_allergies, covariates)
Example input dataframes
ehr_drug_allergies
covariates
Example output covariates
dataframe after requiring allergy list entry
regression_table <- ddiwas::create_regression_table(drug_allergies, covariates)
Example input dataframes.
drug_allergies
covariates
Example output regression_table
dataframe
results <- ddiwas::ddiwas_regression(regression_table, rare_events = TRUE)
object_drug
column. Rearrange and rename columns.
results$object_drug <- "simvastatin"
results <- results %>%
select(object_drug, drug, coef, se, pval, or, nA, nB, nC, nD)
names(results) <- c("object_drug", "potential_precipitant_drug", "coef", "se", "pval", "or", "nA", "nB", "nC", "nD")
Example input regression_table
dataframe.
Example output results
dataframe.
sessionInfo()
#> R version 4.0.4 (2021-02-15)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur 10.16
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] lubridate_1.7.10 glue_1.4.2 ddiwas_0.1 broom_0.7.5
#> [5] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.5 purrr_0.3.4
#> [9] readr_1.4.0 tidyr_1.1.3 tibble_3.1.0 ggplot2_3.3.3
#> [13] tidyverse_1.3.0
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.6 assertthat_0.2.1 rprojroot_2.0.2 digest_0.6.27
#> [5] utf8_1.2.1 R6_2.5.0 cellranger_1.1.0 backports_1.2.1
#> [9] reprex_1.0.0 evaluate_0.14 httr_1.4.2 pillar_1.5.1
#> [13] rlang_0.4.10 readxl_1.3.1 rstudioapi_0.13 DT_0.17
#> [17] rmarkdown_2.7 pkgdown_1.6.1 textshaping_0.3.1 desc_1.2.0
#> [21] htmlwidgets_1.5.3 munsell_0.5.0 compiler_4.0.4 modelr_0.1.8
#> [25] xfun_0.22 pkgconfig_2.0.3 systemfonts_1.0.1 htmltools_0.5.1.1
#> [29] tidyselect_1.1.0 fansi_0.4.2 crayon_1.4.1 dbplyr_2.1.0
#> [33] withr_2.4.1 grid_4.0.4 jsonlite_1.7.2 gtable_0.3.0
#> [37] lifecycle_1.0.0 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1
#> [41] cli_2.3.1 stringi_1.5.3 cachem_1.0.4 fs_1.5.0
#> [45] xml2_1.3.2 ellipsis_0.3.1 ragg_1.1.1 generics_0.1.0
#> [49] vctrs_0.3.6 tools_4.0.4 crosstalk_1.1.1 hms_1.0.0
#> [53] fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-0 rvest_1.0.0
#> [57] memoise_2.0.0 knitr_1.31 haven_2.3.1