-
Notifications
You must be signed in to change notification settings - Fork 0
/
04_gwas_coxph.R
67 lines (56 loc) · 1.41 KB
/
04_gwas_coxph.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
library(future)
library(fastDummies)
if (supportsMulticore()) plan(multicore) else plan(multisession)
options(future.globals.maxSize = 1000 * 1024^2)
source("functions/mk_model_params.R", local = TRUE)
source("functions/run_gwas.R", local = TRUE)
output_dir <- "results/04"
dir.create(output_dir, FALSE, TRUE)
load("results/01/hx_df.rda")
pca <- read.delim(
"results/03/pca5.eigenvec",
header = FALSE,
sep = " "
) |>
setNames(c("FID", "IID", paste0("PC", 1:5)))
covariates_df <- merge(
pca,
hx_df,
by.x = "IID",
by.y = "id",
all.x = TRUE,
sort = FALSE
) |>
dummy_cols(
select_columns = "sex",
remove_first_dummy = TRUE,
remove_selected_columns = TRUE,
ignore_na = TRUE
)
for (event in c("os", "css", "dfs")) {
time <- paste0(event, "_time_days")
covariates <- c("age", grep("PC|sex", names(covariates_df), value = TRUE))
df <- covariates_df[c("IID", covariates, time, event)]
df <- na.omit(df)
df <- df[df[[time]] > 30, , drop = FALSE]
coxph_params <- mk_coxph_params(
covariates_df = df,
id_col = "IID",
time_col = time,
event_col = event,
covariates_col = covariates,
model = FALSE,
x = FALSE,
y = FALSE
)
run_gwas(
bed_file = "results/03/data_final.bed",
model_params = coxph_params,
output_file = file.path(
output_dir,
paste("gwas", event, "coxph", sep = "_")
),
chunk_size = 10000,
min_maf = NULL
)
}