-
Notifications
You must be signed in to change notification settings - Fork 1
/
Snakefile
63 lines (56 loc) · 2.68 KB
/
Snakefile
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
import sys
import pandas as pd
# COLOC pipeline
gwas_data = config["gwas"]
qtl_data = config["qtl"]
outFolder = config["outFolder"]
geneMeta = config["geneMeta"]
# sanity check - can the GWAS and QTL data be found in the database?
gwas_df = pd.read_excel("/sc/arion/projects/ad-omics/data/references/GWAS/GWAS-QTL_data_dictionary.xlsx", sheet_name = "GWAS")
qtl_df = pd.read_excel("/sc/arion/projects/ad-omics/data/references/GWAS/GWAS-QTL_data_dictionary.xlsx", sheet_name = "QTL")
gwas_check = all(i in gwas_df["dataset"].tolist() for i in gwas_data )
qtl_check = all(i in qtl_df["dataset"].tolist() for i in qtl_data )
if not all([gwas_check, qtl_check]):
print(" * QTL and/or GWAS cannot be found in database")
sys.exit()
shell.prefix("export PS1=""; ml anaconda3; CONDA_BASE=$(conda info --base); source $CONDA_BASE/etc/profile.d/conda.sh; ml purge; conda activate snakemake;")
rule all:
input:
#expand(outFolder + "{GWAS}/{QTL}/{QTL}_{GWAS}_coloc_results.snp.1kgp3_ld.tsv.gz", GWAS = gwas_data, QTL = qtl_data)
outFolder + "all_COLOC_results_merged_H4_0_no_LD.tsv.gz",
outFolder + "all_COLOC_results_merged_H4_0.5_with_LD.tsv.gz",
#expand( outFolder + "{GWAS}/{QTL}_{GWAS}_COLOC.tsv", GWAS = gwas_data, QTL = qtl_data )
#outFolder + "all_COLOC_summary_results.tsv.gz"
rule run_COLOC:
output:
outFolder + "{GWAS}/{QTL}_{GWAS}_COLOC.tsv",
outFolder + "{GWAS}/{QTL}_{GWAS}_COLOC.RData"
params:
script = "scripts/run_COLOC.R"
shell:
"mkdir -p {outFolder}{wildcards.GWAS};"
"ml R/4.2.0;" #ml arrow;"
"Rscript {params.script} -g {wildcards.GWAS} -q {wildcards.QTL} -o {outFolder}{wildcards.GWAS}/ "
rule merge_COLOC_snp_level:
input:
expand( outFolder + "{GWAS}/{QTL}_{GWAS}_COLOC.tsv", GWAS = gwas_data, QTL = qtl_data )
output:
outFolder + "all_COLOC_results_merged_H4_0_no_LD.tsv.gz",
outFolder + "all_COLOC_results_merged_H4_0.5_with_LD.tsv.gz"
params:
script = "scripts/merge_COLOC_results.R"
shell:
"ml R/4.2.0;"
"Rscript {params.script} --threshold 0 --inFolder {outFolder} --geneMeta {geneMeta};"
"Rscript {params.script} --threshold 0.5 --ld --inFolder {outFolder} --geneMeta {geneMeta} "
#rule create_LD_tables:
# input:
# outFolder + "{GWAS}/{QTL}_{GWAS}_COLOC.RData"
# output:
# outFolder + "{GWAS}/{QTL}/{QTL}_{GWAS}_coloc_results.snp.1kgp3_ld.tsv.gz"
# params:
# script = "scripts/prepare_gwas_qtls.R",
# out = outFolder + "{GWAS}/{QTL}/"
# shell:
# "conda activate echoR;"
# "Rscript {params.script} -g {wildcards.GWAS} -q {wildcards.QTL} --inFile {input} --outFolder {params.out}"