-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from RhoInc/dashboard-data-updates
Update enrollment data
- Loading branch information
Showing
31 changed files
with
28,463 additions
and
22,442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.DS_Store | ||
|
||
node_modules/ | ||
|
||
.Rout |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
6,052
data/clinical-trials/data-cleaning/dashboard-accrual-over-time.csv
Large diffs are not rendered by default.
Oops, something went wrong.
1,842 changes: 1,842 additions & 0 deletions
1,842
data/clinical-trials/data-cleaning/dashboard-accrual.csv
Large diffs are not rendered by default.
Oops, something went wrong.
1,207 changes: 0 additions & 1,207 deletions
1,207
data/clinical-trials/data-cleaning/dashboard-enrollment-over-time.csv
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
data/clinical-trials/data-cleaning/dashboard-enrollment.csv
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
data/clinical-trials/data-cleaning/scripts/dashboard-accrual-over-time.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
89
data/clinical-trials/data-cleaning/scripts/dashboard-accrual.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Oops, something went wrong.