library(ggplot2)
library(dplyr)
library(Hmisc)
::getRs('reptools.r') Hmisc
Announcing the kidsides R package
We hypothesized that adverse drug reactions manifest from the interaction between drug exposure and dynamic biological processes during child growth and development. The {kidsides} R data package contains half a million drug safety hypotheses.
One of the main research questions during my PhD was how does the biology of childhood interact with medications taken during by children? After years of research and reading the literature my thesis became:
Adverse drug reactions manifest from the interaction between drug exposure and dynamic biological processes during child growth and development.
To investigate, we generated thousands of statistical signals of the interaction between pediatric population drug reporting and the child development stage resulting in an adverse event1. For more details the reference is freely available at this reference1.
g(E(Adverse reaction)) = spline(stage, by = Drug)
The {kidsides}
R data package makes this database more accessible by caching the SQLite database on your machine. You can read up more regarding installation at the website https://kidsides.nickg.bio. Additionally, there is an overview on the data within the database at this vignette, and a tutorial on extracting smaller, more manageable datasets in this vignette.
Your main questions about {kidsides}
may be what data do the tables have and what kind of graphics could I make? In this post, I want to
- Give a preview of all 17 tables in the SQLite database.
- Show how the strength of the hypothesized interactions depending on the class of a medication, such as cardiovascular or psychiatric drug class. Interaction investigated here: Number of reports for an adverse drug event vs. Estimated drug safety signal.
I will make use of Frank Harrell’s reptools R code that will make individual tabs in this document for each table/graph below.
There are only 3 functions that come with {kidsides}
. Once {kidsides}
is installed from CRAN, you can easily cache the database with the following command:
::download_sqlite_db() kidsides
The cache location is determined by the {tools}
package. Using the other two functions in {kidsides}
, you can easily connect and disconnect from the database, respectively.
Now, onto the showcases!
<- kidsides::connect_sqlite_db() con
<- DBI::dbListTables(con)
tables
<- purrr::map(tables,~{
items ::datatable(tbl(con,.x) %>%
DThead(100) %>%
collect(),
options = list(dom = 'tf',
pageLength=5,
scrollX = TRUE,
deferRender = TRUE,
scrollY = 500,
scroller = TRUE),
extensions = 'Scroller')
})names(items) <- tables
maketabs(items)
<- tbl(con,'event') %>%
soc_categories select(meddra_concept_name_4) %>%
distinct() %>%
collect() %>%
na.omit() %>%
pull()
<- purrr::map(soc_categories,~{
items <-
soc_events tbl(con,'event') %>%
filter(meddra_concept_name_4==.x) %>%
select(meddra_concept_id) %>%
distinct() %>%
collect() %>% pull() %>% na.omit()
<- tbl(con,'ade') %>%
soc_ades filter(meddra_concept_id %in% soc_events &
%>%
gt_null_99) select(ade) %>%
distinct() %>%
collect() %>% pull() %>% na.omit()
<- tbl(con,'ade_nichd') %>%
tmp filter(ade %in% soc_ades) %>%
select(ade,nichd,gam_score_90mse,DE) %>% collect()
<- 0.0001
eps <-
ades_ordered arrange(tmp,gam_score_90mse) %>%
slice(1,.by=ade) %>% pull(ade) %>% factor()
<-
ade_cluster_map tbl(con,'ade') %>%
select(ade,cluster_name) %>%
filter(ade %in% soc_ades) %>%
collect()
<-
plot_tmp %>%
tmp left_join(ade_cluster_map,by='ade') %>%
mutate(
ade = factor(ade,levels=ades_ordered),
nichd = factor(nichd,levels=c('term_neonatal',
'infancy','toddler','early_childhood',
'middle_childhood','early_adolescence',
'late_adolescence')),
signal = if_else(gam_score_90mse>0,gam_score_90mse,eps))
$DE_cut <-
plot_tmpcut(plot_tmp$DE,breaks = c(0,1,5,50,as.integer(max(plot_tmp$DE))),include.lowest = T)
<- position_dodge2(width = 0.7)
pos <- plot_tmp %>%
p ggplot(aes(nichd,signal,group=ade)) +
geom_line(alpha=0.2,position = pos) +
geom_jitter(aes(fill=DE_cut),pch=21,size=3,position = pos) +
guides(fill=guide_legend(title='Number of Reports',
title.position = 'top')) +
scale_color_brewer(palette = 'Set1') +
scale_fill_viridis_d() +
scale_y_sqrt() +
labs(x="Number of Reports",
y='Statistical Signal (lower bound)') +
facet_wrap(~cluster_name,ncol=2) +
theme_linedraw(base_size = 16) +
theme(
axis.text.x = element_text(angle=45,vjust=1,hjust=1),
legend.position = 'top'
)
p
})names(items) <- soc_categories
maketabs(items)
Phew, that was a lot of information! No worries, feel free to look through the {kidsides}
website and the vignettes. Hopefully you will see it is easy to access and extract data from this database.
There are so many questions, visualizations, and analyses to be made with this data. I hope this short post provides a sneak peak into the database to wet your palette for more explorations. If you use this database in your work, I would love to hear about it!
::disconnect_sqlite_db(con) kidsides