Allow specifying a --where clause for `gene_wise` to filter considered variants. (Thanks Uma for suggestion).
MODIFY
docs/content/history.rst
docs/content/history.rst
@@ -16,6 +16,7 @@ Release History
#. Add extra columns from VEP when -t all is used (previously extra VEP columns were ignored under -t all. thanks @hoppman #816).
#. Fix gemini annotate (would stop after updating 100K variants)
#. Fix browser query report (thanks @Nmael see #818).
+#. Allow specifying a --where clause for `gene_wise` to filter considered variants. (Thanks Uma for suggestion).
0.19.1
======

MODIFY
docs/content/tools.rst
docs/content/tools.rst
@@ -807,6 +807,20 @@ E.g.
will required that all samples meet the minimum depth filter and then keep
the subset of those that meet 2 out of the 3 `--gt-filters`.
+---------------
+``--where``
+---------------
+
+By default `gene_wise` limits to variants passing the clause:
+
+`is_exonic = 1 AND impact_severity != 'LOW'`
+
+but this can be changed with the --where clause, e.g.:
+
+::
+
+ --where "(is_exonic = 1 or is_splicing = 1) AND impact_severity != 'LOW'"
+
===========================================================================
``pathways``: Map genes and variants to KEGG pathways.

MODIFY
gemini/genewise.py
gemini/genewise.py
@@ -15,6 +15,8 @@ def add_args(a=None):
if a is None:
a = ArgumentParser()
a.add_argument("--min-filters", type=int, default=1)
+ a.add_argument("--where", default="is_exonic = 1 AND impact_severity != 'LOW'",
+ help="where clause to subset variants. [default \"%(default)s\"]")
a.add_argument("--gt-filter", required=False, default=[], action='append')
a.add_argument("--gt-filter-required", required=False, default=[],
action='append', help="specify filter(s) that must be met."
@@ -82,6 +84,7 @@ def gen_results(rows, gt_filters, gt_req_filters, min_filters, min_variants, col
def genewise(db, gt_filters, gt_req_filters, filter=None, columns=None, min_filters=None,
min_variants=1,
+ where=None,
grouper="gene"):
assert os.path.exists(db)
@@ -95,7 +98,7 @@ def genewise(db, gt_filters, gt_req_filters, filter=None, columns=None, min_filt
assert not any(';' in c for c in columns)
# NOTE: we could make the WHERE part customizable.
- query = "SELECT {columns} FROM variants WHERE (is_exonic = 1 AND impact_severity != 'LOW')"
+ query = "SELECT {columns} FROM variants WHERE (%s)" % where
if filter:
query += " AND " + filter
query += (" ORDER BY CHROM, %s" % grouper)
@@ -147,4 +150,4 @@ def run(args):
raise RuntimeError("ERROR gene-wise: specified neither --min-filter or --min-filter-required\n")
genewise(args.db, args.gt_filter, args.gt_filter_required, args.filter, args.columns,
- args.min_filters)
+ args.min_filters, where=args.where)

MODIFY
test/test-genewise.sh
test/test-genewise.sh
@@ -96,3 +96,17 @@ gemini gene_wise \
--min-filters 1 \
test.auto_dom.db > obs
check obs exp
+
+echo "genewise.t7"
+echo "gene chrom start end ref alt impact impact_severity variant_filters n_gene_variants gene_filters
+WDR37 chr10 1142207 1142208 T C stop_lost HIGH required[1],1 2 1
+WDR37 chr10 1142208 1142209 T C stop_lost HIGH required[1],1 2 1" > exp
+
+gemini gene_wise \
+ --columns "gene, chrom, start, end, ref, alt, impact, impact_severity" \
+ --gt-filter-required "((gt_types).(phenotype==1).(==HOM_ALT).(none))" \
+ --gt-filter "((gt_types).(phenotype==1).(==HOM_ALT).(none))" \
+ --where "is_exonic = 1 AND impact_severity == 'HIGH'" \
+ --min-filters 1 \
+ test.auto_dom.db > obs
+check obs exp

Allow specifying a --where clause for `gene_wise` to filter considered variants. (Thanks Uma for suggestion).