-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_index_workspaces.R
269 lines (206 loc) · 10.2 KB
/
make_index_workspaces.R
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# goals
#
# make consortium "index workspace" that has a set of tables for each consent
# group that combines data from RC upload workspaces
#
# target workspace is
# https://app.terra.bio/#workspaces/GREGoR-ben/GREGoR_DCC_consortium_index_demo
library(AnVIL)
library(tidyverse)
# define the workspaces we're working with
RC_1_HMB_project <- avworkspace_namespace()
RC_1_HMB_workspace <- "GREGoR_DCC_RC1_HMB_demo"
RC_1_HMB_bucket <- avbucket(project, name = workspace)
RC_2_HMB_project <- avworkspace_namespace()
RC_2_HMB_workspace <- "GREGoR_DCC_RC2_HMB_demo"
RC_2_HMB_bucket <- avbucket(project, name = workspace)
RC_1_GRU_project <- avworkspace_namespace()
RC_1_GRU_workspace <- "GREGoR_DCC_RC1_GRU_demo"
RC_1_GRU_bucket <- avbucket(project, name = workspace)
RC_2_GRU_project <- avworkspace_namespace()
RC_2_GRU_workspace <- "GREGoR_DCC_RC2_GRU_demo"
RC_2_GRU_bucket <- avbucket(project, name = workspace)
release_GRU_project <- avworkspace_namespace()
release_GRU_workspace <- "GREGoR_DCC_GRU_release_index_demo"
release_GRU_bucket <- avbucket(project, name = workspace)
release_HMB_project <- avworkspace_namespace()
release_HMB_workspace <- "GREGoR_DCC_HMB_release_index_demo"
release_HMB_bucket <- avbucket(project, name = workspace)
consortium_index_project <- avworkspace_namespace()
consortium_index_workspace <- "GREGoR_DCC_consortium_index_demo"
consortium_index_bucket <- avbucket(project, name = workspace)
# first, combine HMB data tables from GREGoR_DCC_RC1_HMB_demo and from GREGoR_DCC_RC2_HMB_demo
## participant tables
# load data from source workspace data tables to R data frames
RC_1_HMB_participant_table <-
avtable("participant", namespace = RC_1_HMB_project,
name = RC_1_HMB_workspace)
RC_2_HMB_participant_table <-
avtable("participant", namespace = RC_2_HMB_project,
name = RC_2_HMB_workspace)
combined_participant_table <-
bind_rows(RC_1_HMB_participant_table, RC_2_HMB_participant_table) %>%
mutate("entity:HMB_participant_id" = participant_id,
.before = "participant_id")
avtable_import(combined_participant_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the HMB "release" index workspace
avtable_import(combined_participant_table, namespace = release_HMB_project,
name = release_HMB_workspace)
## biosample tables
# load data from source workspace data tables to R data frames
RC_1_HMB_biosample_table <-
avtable("biosample", namespace = RC_1_HMB_project,
name = RC_1_HMB_workspace)
RC_2_HMB_biosample_table <-
avtable("biosample", namespace = RC_2_HMB_project,
name = RC_2_HMB_workspace)
combined_biosample_table <-
bind_rows(RC_1_HMB_biosample_table, RC_2_HMB_biosample_table) %>%
mutate("entity:HMB_biosample_id" = biosample_id,
.before = "biosample_id")
avtable_import(combined_biosample_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the HMB "release" index workspace
avtable_import(combined_biosample_table, namespace = release_HMB_project,
name = release_HMB_workspace)
## experiment tables
# load data from source workspace data tables to R data frames
RC_1_HMB_experiment_table <-
avtable("experiment", namespace = RC_1_HMB_project,
name = RC_1_HMB_workspace)
RC_2_HMB_experiment_table <-
avtable("experiment", namespace = RC_2_HMB_project,
name = RC_2_HMB_workspace)
combined_experiment_table <-
bind_rows(RC_1_HMB_experiment_table, RC_2_HMB_experiment_table) %>%
mutate("entity:HMB_experiment_id" = experiment_id,
.before = "experiment_id")
avtable_import(combined_experiment_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the HMB "release" index workspace
avtable_import(combined_experiment_table, namespace = release_HMB_project,
name = release_HMB_workspace)
## phenotype tables
# load data from source workspace data tables to R data frames
RC_1_HMB_phenotype_table <-
avtable("phenotype", namespace = RC_1_HMB_project,
name = RC_1_HMB_workspace)
RC_2_HMB_phenotype_table <-
avtable("phenotype", namespace = RC_2_HMB_project,
name = RC_2_HMB_workspace)
combined_phenotype_table <-
bind_rows(RC_1_HMB_phenotype_table, RC_2_HMB_phenotype_table) %>%
mutate("entity:HMB_phenotype_id" = phenotype_id,
.before = "phenotype_id")
avtable_import(combined_phenotype_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the HMB "release" index workspace
avtable_import(combined_phenotype_table, namespace = release_HMB_project,
name = release_HMB_workspace)
## aligned_short_reads tables
# load data from source workspace data tables to R data frames
RC_1_HMB_aligned_short_reads_table <-
avtable("aligned_short_reads", namespace = RC_1_HMB_project,
name = RC_1_HMB_workspace)
RC_2_HMB_aligned_short_reads_table <-
avtable("aligned_short_reads", namespace = RC_2_HMB_project,
name = RC_2_HMB_workspace)
combined_aligned_short_reads_table <-
bind_rows(RC_1_HMB_aligned_short_reads_table, RC_2_HMB_aligned_short_reads_table) %>%
mutate("entity:HMB_aligned_short_reads_id" = aligned_short_reads_id,
.before = "aligned_short_reads_id")
avtable_import(combined_aligned_short_reads_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the HMB "release" index workspace
avtable_import(combined_aligned_short_reads_table, namespace = release_HMB_project,
name = release_HMB_workspace)
# next, combine GRU data tables from GREGoR_DCC_RC1_GRU_demo and from GREGoR_DCC_RC2_GRU_demo
## participant tables
# load data from source workspace data tables to R data frames
RC_1_GRU_participant_table <-
avtable("participant", namespace = RC_1_GRU_project,
name = RC_1_GRU_workspace)
RC_2_GRU_participant_table <-
avtable("participant", namespace = RC_2_GRU_project,
name = RC_2_GRU_workspace)
combined_participant_table <-
bind_rows(RC_1_GRU_participant_table, RC_2_GRU_participant_table) %>%
mutate("entity:GRU_participant_id" = participant_id,
.before = "participant_id")
avtable_import(combined_participant_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the GRU "release" index workspace
avtable_import(combined_participant_table, namespace = release_GRU_project,
name = release_GRU_workspace)
## biosample tables
# load data from source workspace data tables to R data frames
RC_1_GRU_biosample_table <-
avtable("biosample", namespace = RC_1_GRU_project,
name = RC_1_GRU_workspace)
RC_2_GRU_biosample_table <-
avtable("biosample", namespace = RC_2_GRU_project,
name = RC_2_GRU_workspace)
combined_biosample_table <-
bind_rows(RC_1_GRU_biosample_table, RC_2_GRU_biosample_table) %>%
mutate("entity:GRU_biosample_id" = biosample_id,
.before = "biosample_id")
avtable_import(combined_biosample_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the GRU "release" index workspace
avtable_import(combined_biosample_table, namespace = release_GRU_project,
name = release_GRU_workspace)
## experiment tables
# load data from source workspace data tables to R data frames
RC_1_GRU_experiment_table <-
avtable("experiment", namespace = RC_1_GRU_project,
name = RC_1_GRU_workspace)
RC_2_GRU_experiment_table <-
avtable("experiment", namespace = RC_2_GRU_project,
name = RC_2_GRU_workspace)
combined_experiment_table <-
bind_rows(RC_1_GRU_experiment_table, RC_2_GRU_experiment_table) %>%
mutate("entity:GRU_experiment_id" = experiment_id,
.before = "experiment_id")
avtable_import(combined_experiment_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the GRU "release" index workspace
avtable_import(combined_experiment_table, namespace = release_GRU_project,
name = release_GRU_workspace)
## phenotype tables
# load data from source workspace data tables to R data frames
RC_1_GRU_phenotype_table <-
avtable("phenotype", namespace = RC_1_GRU_project,
name = RC_1_GRU_workspace)
RC_2_GRU_phenotype_table <-
avtable("phenotype", namespace = RC_2_GRU_project,
name = RC_2_GRU_workspace)
combined_phenotype_table <-
bind_rows(RC_1_GRU_phenotype_table, RC_2_GRU_phenotype_table) %>%
mutate("entity:GRU_phenotype_id" = phenotype_id,
.before = "phenotype_id")
avtable_import(combined_phenotype_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the GRU "release" index workspace
avtable_import(combined_phenotype_table, namespace = release_GRU_project,
name = release_GRU_workspace)
## aligned_short_reads tables
# load data from source workspace data tables to R data frames
RC_1_GRU_aligned_short_reads_table <-
avtable("aligned_short_reads", namespace = RC_1_GRU_project,
name = RC_1_GRU_workspace)
RC_2_GRU_aligned_short_reads_table <-
avtable("aligned_short_reads", namespace = RC_2_GRU_project,
name = RC_2_GRU_workspace)
combined_aligned_short_reads_table <-
bind_rows(RC_1_GRU_aligned_short_reads_table, RC_2_GRU_aligned_short_reads_table) %>%
mutate("entity:GRU_aligned_short_reads_id" = aligned_short_reads_id,
.before = "aligned_short_reads_id")
avtable_import(combined_aligned_short_reads_table, namespace = consortium_index_project,
name = consortium_index_workspace)
# also put this combined data table in the GRU "release" index workspace
avtable_import(combined_aligned_short_reads_table, namespace = release_GRU_project,
name = release_GRU_workspace)
# Copy this script into current bucket
bucket <- avbucket()
gsutil_cp("./make_index_workspaces.R", bucket)