Skip to content

Commit

Permalink
Merge pull request #36 from RhoInc/dashboard-data-updates
Browse files Browse the repository at this point in the history
Update enrollment data
  • Loading branch information
samussiah authored Aug 6, 2019
2 parents 618a76d + e636005 commit f903a53
Show file tree
Hide file tree
Showing 31 changed files with 28,463 additions and 22,442 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store

node_modules/

.Rout
786 changes: 393 additions & 393 deletions data/clinical-trials/adam/adae.csv

Large diffs are not rendered by default.

706 changes: 353 additions & 353 deletions data/clinical-trials/adam/adcm.csv

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions data/clinical-trials/adam/adsl.csv

Large diffs are not rendered by default.

6,340 changes: 3,170 additions & 3,170 deletions data/clinical-trials/adam/advs.csv

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions data/clinical-trials/adam/scripts/run-scripts.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
rem Make sure Rpath is pointing to your local install of R.
set Rpath="C:\Program Files\R\R-3.3.2\bin\R.exe"
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_DM.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_AE.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_CM.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_SV.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet labs.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_LB.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_VS.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet create_anly.R
set Rpath="C:\Program Files\R\R-3.4.3\bin\R.exe"
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet adae.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet adcm.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet adlb.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet adsl.R
%Rpath% CMD BATCH --no-save --vanilla --slave --quiet advs.R
6,052 changes: 6,052 additions & 0 deletions data/clinical-trials/data-cleaning/dashboard-accrual-over-time.csv

Large diffs are not rendered by default.

1,842 changes: 1,842 additions & 0 deletions data/clinical-trials/data-cleaning/dashboard-accrual.csv

Large diffs are not rendered by default.

1,207 changes: 0 additions & 1,207 deletions data/clinical-trials/data-cleaning/dashboard-enrollment-over-time.csv

This file was deleted.

70 changes: 0 additions & 70 deletions data/clinical-trials/data-cleaning/dashboard-enrollment.csv

This file was deleted.

35 changes: 21 additions & 14 deletions data/clinical-trials/data-cleaning/data-files.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
[
{
"relPath": "./data/clinical-trials/data-cleaning/dashboard-enrollment-over-time.csv",
"path": "dashboard-enrollment-over-time.csv",
"name": "dashboard-enrollment-over-time",
"nRows": 1206,
"relPath": "./data/clinical-trials/data-cleaning/dashboard-accrual-over-time.csv",
"path": "dashboard-accrual-over-time.csv",
"name": "dashboard-accrual-over-time",
"nRows": 6051,
"cols": [
"site",
"date",
"population",
"population_order",
"population_color",
"date",
"participant_count"
],
"nCols": 6
},
{
"relPath": "./data/clinical-trials/data-cleaning/dashboard-enrollment.csv",
"path": "dashboard-enrollment.csv",
"name": "dashboard-enrollment",
"nRows": 69,
"relPath": "./data/clinical-trials/data-cleaning/dashboard-accrual.csv",
"path": "dashboard-accrual.csv",
"name": "dashboard-accrual",
"nRows": 263,
"cols": [
"site",
"subjid",
"population",
"population_order",
"population_color",
"population_superset"
"population_superset",
"date",
"site",
"site_abbreviation",
"site_info",
"filter:Arm",
"listing:Age",
"listing:Sex",
"listing:Race"
],
"nCols": 5
"nCols": 13
},
{
"relPath": "./data/clinical-trials/data-cleaning/dashboard-forms.csv",
Expand Down Expand Up @@ -137,7 +145,6 @@
"subjectnameoridentifier",
"subject_status",
"visit_name",
"visit_abbreviation",
"visit_number",
"visit_date",
"visit_day",
Expand All @@ -152,6 +159,6 @@
"overdue2",
"plot_exclude"
],
"nCols": 18
"nCols": 17
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
library(data.table)
library(tidyverse)
library(lubridate)

# input data
accrual <- '../dashboard-accrual.csv' %>%
fread(
sep = ',',
na.strings = '',
colClasses = 'character'
)
sites <- '../../data-dictionaries/sites.csv' %>%
fread(
sep = ',',
na.strings = '',
colClasses = 'character'
)

# data manipulation

# target
target <- sites %>%
mutate(
population = 'Target',
population_order = 3,
population_color = '#034e7b',
population_superset = '',
target_rate = as.numeric(site_target)/as.numeric(site_accrual_duration)
) %>%
group_by(
population, population_order, population_color, population_superset, site, site_abbreviation, site_accrual_start_date, accrual_end_date, target_rate
) %>%
do(data.frame(
date = seq(ymd(.$site_accrual_start_date), ymd(.$accrual_end_date), by = '1 day'),
stringsAsFactors = FALSE
)) %>%
mutate(
participant_count = cumsum(target_rate)
) %>%
ungroup() %>%
select(
-site_accrual_start_date, -accrual_end_date, -target_rate
) %>%
mutate(
date = as.character(date)
)

# screened and randomized
shell <- target %>%
select(
-starts_with('population'), -participant_count
)

# screened
screened <- accrual %>%
filter(
population == 'Screened'
) %>%
select(
starts_with('population')
) %>%
unique
screened1 <- shell %>%
mutate(
population = rep(screened$population, nrow(shell)),
population_order = rep(screened$population_order, nrow(shell)),
population_color = rep(screened$population_color, nrow(shell)),
population_superset = rep(screened$population_superset, nrow(shell))
)

# randomized
randomized <- accrual %>%
filter(
population == 'Randomized'
) %>%
select(
starts_with('population')
) %>%
unique
randomized1 <- shell %>%
mutate(
population = rep(randomized$population, nrow(shell)),
population_order = rep(randomized$population_order, nrow(shell)),
population_color = rep(randomized$population_color, nrow(shell)),
population_superset = rep(randomized$population_superset, nrow(shell))
)

# count participants by date, population, and site
participantCounts <- accrual %>%
group_by(
population, population_order, population_color, population_superset, date, site, site_abbreviation
) %>%
summarize(
participant_count = n()
) %>%
ungroup()

# merge population shells with participant counts
accrualOverTime <- screened1 %>%
rbind(randomized1) %>%
left_join(
participantCounts
) %>%
mutate(
participant_count = ifelse(
is.na(participant_count),
0,
participant_count
)
) %>%
group_by(
population, population_order, population_color, population_superset, site, site_abbreviation
) %>%
mutate(
participant_count = cumsum(participant_count) # cumulatively sum participant counts by population and site
) %>%
ungroup %>%
rbind(target) %>%
arrange(
site, population_order, date
) %>%
select(
site, population, population_order, population_color, date, participant_count
)

# output data
accrualOverTime %>%
fwrite(
'../../data-cleaning/dashboard-accrual-over-time.csv',
na = '',
row.names = FALSE
)
89 changes: 89 additions & 0 deletions data/clinical-trials/data-cleaning/scripts/dashboard-accrual.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
library(data.table)
library(tidyverse)

# input data
dm <- '../../sdtm/dm.csv' %>%
fread(
sep = ',',
na.strings = '',
colClasses = 'character'
)
sv <- '../../sdtm/sv.csv' %>%
fread(
sep = ',',
na.strings = '',
colClasses = 'character'
)
sites <- '../../data-dictionaries/sites.csv' %>%
fread(
sep = ',',
na.strings = '',
colClasses = 'character'
)

# data manipulation

# screened population
screened <- dm %>%
select(
USUBJID, RFSTDTC
) %>%
rename(
subjid = USUBJID,
date = RFSTDTC
) %>%
mutate(
population = 'Screened',
population_order = 1,
population_color = '#a6bddb',
population_superset = ''
)

# randomized popluation
randomized <- sv %>%
filter(
VISIT == 'Visit 1' & SVSTATUS == 'Completed'
) %>%
select(USUBJID, SVDT) %>%
rename(
subjid = USUBJID,
date = SVDT
) %>%
mutate(
population = 'Randomized',
population_order = 2,
population_color = '#3690c0',
population_superset = 'Screened'
)

# stacked, merged with DM, merged with sites
accrual <- screened %>%
rbind(randomized) %>%
left_join(
dm %>% select(USUBJID, SITEID, AGE, SEX, RACE, ARM),
by = c('subjid' = 'USUBJID')
) %>%
left_join(
sites %>% select(site, site_id, site_abbreviation, site_info),
by = c('SITEID' = 'site_id')
) %>%
select(
subjid, population, population_order, population_color, population_superset, date, site, site_abbreviation, site_info, ARM, AGE, SEX, RACE
) %>%
rename(
`filter:Arm` = ARM,
`listing:Age` = AGE,
`listing:Sex` = SEX,
`listing:Race` = RACE
) %>%
arrange(
subjid, population_order
)

# output data
accrual %>%
fwrite(
'../../data-cleaning/dashboard-accrual.csv',
na = '',
row.names = FALSE
)
Loading

0 comments on commit f903a53

Please sign in to comment.