Skip to content

Commit eec8f0b

Browse files
authored
Create bootstrap_models.R
1 parent c022db3 commit eec8f0b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

bootstraps/bootstrap_models.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Resample mutation data to create 100 bootstrap models
2+
# Bootstrap estimates calculated distributed cluster call in bootstrap_call.R
3+
4+
phased_boot_models <- lapply(replicate(100, list(sample.int(nrow(agg_phased_filtered),
5+
size = nrow(agg_phased_filtered),
6+
replace = TRUE))),
7+
FUN = function(sampled_row_idx) {
8+
dup_idx <- which(duplicated(sampled_row_idx))
9+
boot_data <- agg_phased_filtered[sampled_row_idx,]
10+
out <-
11+
purrr::quietly(MGLMreg)(formula = cbind(A_C, A_G, A_T, C_A, C_G, C_T) ~
12+
Fathers_age_at_conception + Mothers_age_at_conception,
13+
dist = "DM",
14+
data = boot_data)
15+
if(length(grep("hessian", out$warnings)) > 0)
16+
return(NA)
17+
else
18+
return(out$result)
19+
})
20+
21+
unphased_boot_models <- lapply(replicate(100, list(sample.int(nrow(agg_unphased_filtered),
22+
size = nrow(agg_unphased_filtered),
23+
replace = TRUE))),
24+
FUN = function(sampled_row_idx) {
25+
boot_data <- agg_unphased_filtered[sampled_row_idx,]
26+
out <-
27+
purrr::quietly(MGLMreg)(formula = cbind(A_C, A_G, A_T, C_A, C_G, C_T) ~
28+
Fathers_age_at_conception + Mothers_age_at_conception,
29+
dist = "DM",
30+
data = boot_data)
31+
if(length(grep("hessian", out$warnings)) > 0)
32+
return(NA)
33+
else
34+
return(out$result)
35+
})

0 commit comments

Comments
 (0)