Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chrom regex filter #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wdl/gwas/saige.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"saige.test_combine.test.minmac": 5,
"saige.test_combine.test.logP": true,
"saige.test_combine.combine.logP": true,
"saige.test_combine.combine.chrom_regex": "^chr(([0-9]{1,2})|([XYM]))$",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant for current functioning but while at this I would make chr optional in case this is used for data without a chr prefix. Also would add XYMT in case there's mitochondrial as MT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, how about this:

Suggested change
"saige.test_combine.combine.chrom_regex": "^chr(([0-9]{1,2})|([XYM]))$",
"saige.test_combine.combine.chrom_regex": "^(chr)?(([0-9]{1,2})|([XYM]|MT))$",

Now chr is optional (matched 0 or 1 times) and chromosome can be 0-99, X,Y,M,MT


"saige.test_combine.combine.prefix": "finngen_R7_",
"saige.test_combine.combine.chrcol": "#chrom",
Expand Down
8 changes: 6 additions & 2 deletions wdl/gwas/saige_sub.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ task combine {
String prefix
Boolean logP
String logPStr = if logP then "True" else "False"
String chrom_regex

command <<<
set -euxo pipefail
Expand All @@ -96,7 +97,7 @@ task combine {

echo "`date` converting results to ${prefix}${pheno}.gz"
python3 <<EOF | sort -k 1,1g -k 2,2g | bgzip > ${prefix}${pheno}.gz
import math, gzip
import math, gzip, re
from collections import OrderedDict
from functools import reduce

Expand All @@ -106,6 +107,8 @@ task combine {
def red(obj, func_list):
return "NA" if obj == "NA" else reduce(lambda o, func: func[0](o, *func[1]) if func[0] is not str.format else func[0](func[1], o), func_list, obj)

reg = re.compile("${chrom_regex}")

if "${traitType}" == "quantitative":
mapping = OrderedDict([
("#chrom", ("CHR", [(str.replace, ("chr", "")), (str.replace, ("X", "23")), (str.replace, ("Y", "24")), (str.replace, ("MT", "25")), (str.replace, ("M", "25"))])),
Expand Down Expand Up @@ -146,7 +149,8 @@ task combine {
print('\t'.join(mapping.keys()))
for line in f:
s = line.strip().split('\t')
print('\t'.join(str(red(s[header[v[0]]], v[1])) for v in mapping.values()))
if reg.match(s[0]):#match searches from the beginning of the string, which in this case is what we want
print('\t'.join(str(red(s[header[v[0]]], v[1])) for v in mapping.values()))
EOF
echo "`date` plotting qq and manha"
qqplot.R --file ${prefix}${pheno}.gz --bp_col "${bp_col}" --pval_col "${p_valcol}" --chrcol "${chrcol}" --loglog_pval ${loglog_pval}
Expand Down
3 changes: 2 additions & 1 deletion wdl/gwas/saige_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"saige.test_combine.test.minmac": 5,
"saige.test_combine.test.logP": true,
"saige.test_combine.combine.logP": true,
"saige.test_combine.combine.chrom_regex": "^chr(([0-9]{1,2})|([XYM]))$",

"saige.test_combine.combine.prefix": "",
"saige.test_combine.combine.chrcol": "#chrom",
"saige.test_combine.combine.p_valcol": "pval",
"saige.test_combine.combine.bp_col": "pos",
"saige.test_combine.combine.loglog_pval": 10,
"saige.test_combine.combine.loglog_pval": 10
}