Repository navigation
Expand file tree
/
Copy pathtest_script.R
More file actions
99 lines (77 loc) · 3.43 KB
/
Copy pathtest_script.R
File metadata and controls
99 lines (77 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# (X) Make sure handles interim sacrifices and recovery sacrifices properly and ensure documentation reflects this logic
# Double check BW Scoring
# add argument to calculate scores within SEX
# add argument to filter by organ system (or not)
# add argument to calculate LB as change from baseline (if baseline data is present) -- perhaps make this the default
# Update xpt_dir functionality to enable reading from multiple datasets
# Develop a python implementation of this package
# We will work by reading from database rather than raw XPT files
## Kevin will create a SQLite database (using sendigR) that we can all use
## Kevin will provide training an documentation for how to use sendigR to do this
## leave raw XPT reading
## don't run lot's of SQL queries but rather pull domain data out into data frames
rm(list = ls())
setwd(dirname(this.path::this.path()))
devtools::load_all()
DBflag <- F
Domains <- c('bw', 'lb', 'mi')
if (DBflag == T) {
study_dirs <- list.files('sample_data', full.names = F)
} else {
study_dirs <- list.files('sample_data', full.names = T)
# Scores_all <- list()
# study_dir <- "sample_data/35449"
for (study_dir in study_dirs[1:4]) {
print(study_dir)
# # Create tibbles for each domain
# Files <- list.files(study_dir)
# for (File in Files) {
# Domain <- toupper(unlist(strsplit(File, '.', fixed = T))[1])
# assign(Domain, haven::read_xpt(paste0(study_dir, '/', File)))
# }
if (DBflag == T) {
ARGs <- list(
studyid = study_dir,
path_db = 'path/to/db'
)
} else {
ARGs <- list(
xpt_dir = study_dir
)
}
# figiure out how to pass these arguments
ARGs <- list('xpt-dir' = 'XPT_DIR')
Doses <- get_doses(ARGs)
Doses <- get_doses(xpt_dir = XPT_DIR)
treatmentGroups <- get_treatment_group(xpt_dir = study_dir)
print(treatmentGroups)
Compiled_Data <- get_compile_data(xpt_dir = study_dir)
BWscores <- get_bw_score(xpt_dir = study_dir,
master_CompileData = Compiled_Data,
score_in_list_format = F)
BWscoresList <- get_bw_score(xpt_dir = study_dir,
master_CompileData = Compiled_Data,
score_in_list_format = T)
LBscores <- get_lb_score(xpt_dir = study_dir,
master_CompileData = Compiled_Data,
score_in_list_format = F)
LBscoresList <- get_lb_score(xpt_dir = study_dir,
master_CompileData = Compiled_Data,
score_in_list_format = T)
MIscores <- get_mi_score(xpt_dir = study_dir,
master_CompileData = Compiled_Data,
score_in_list_format = F)
MIscoresList <- get_mi_score(xpt_dir = study_dir,
master_CompileData = Compiled_Data,
score_in_list_format = T)
Scores <- get_all_score(xpt_dir = study_dir, domain = Domains, score_in_list_format = F)
scoresList <- get_all_score(xpt_dir = study_dir, domain = Domains, score_in_list_format = T)
if (study_dir == study_dirs[1]) {
Scores_all <- Scores[Domains]
scoresList_all <- scoresList[Domains]
}
for (Domain in Domains) {
Scores_all[[Domain]] <- rbind(Scores_all[[Domain]], Scores[[Domain]])
}
}
}