Skip to content

Commit

Permalink
Updated filtering scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasrausch committed Feb 24, 2014
1 parent 54fbbed commit ff02f20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/populationFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,24 @@ def overlapValid(s1, e1, s2, e2, reciprocalOverlap=0.5, maxOffset=500):
if (not args.siteFilter) or (len(record.FILTER) == 0):
gqRef = []
gqAlt = []
ratioRef = []
ratioRef = [0]
ratioAlt = []
carrierSample = False
if sampleID == "":
carrierSample = True
for call in record.samples:
if (call.called):
if call.gt_type == 0:
if (call['DV'] == 0) and (call['FT'] == "PASS"):
#if (call['FT'] == "PASS") and (call['DV'] == 0):
if (call['DV'] == 0): # More stringent because then the GQ cutoffs demand that only very few samples are LowQual
gqRef.append(call['GQ'])
else:
ratioRef.append(float(call['DV'])/float(call['DR'] + call['DV']))
if call.gt_type != 0:
if (call['FT'] == "PASS"):
if (not carrierSample) and (call.sample == sampleID):
carrierSample = True
if (not carrierSample) and (call.sample == sampleID):
carrierSample = True
#if (call['FT'] == "PASS") and (call['DV'] >= 2):
if (call['DV'] >= 2): # More stringent because then the GQ cutoffs demand that only very few samples are LowQual
gqAlt.append(call['GQ'])
ratioAlt.append(float(call['DV'])/float(call['DR'] + call['DV']))
if carrierSample:
Expand Down
10 changes: 6 additions & 4 deletions src/somaticFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def overlapValid(s1, e1, s2, e2, reciprocalOverlap=0.5, maxOffset=500):
parser.add_argument('-v', '--vcf', metavar='variants.vcf', required=True, dest='vcfFile', help='input vcf file (required)')
parser.add_argument('-o', '--out', metavar='out.vcf', required=True, dest='outFile', help='output vcf file (required)')
parser.add_argument('-t', '--type', metavar='DEL', required=True, dest='svType', help='SV type [DEL, DUP, INV] (required)')
parser.add_argument('-a', '--altaf', metavar='0.25', required=False, dest='altAF', help='min. alt. AF (optional)')
parser.add_argument('-m', '--minsize', metavar='500', required=False, dest='minSize', help='min. size (optional)')
parser.add_argument('-n', '--maxsize', metavar='500000000', required=False, dest='maxSize', help='max. size (optional)')
parser.add_argument('-f', '--filter', dest='siteFilter', action='store_true', help='Filter sites for PASS')
Expand All @@ -39,6 +40,9 @@ def overlapValid(s1, e1, s2, e2, reciprocalOverlap=0.5, maxOffset=500):
maxSize = 500000000
if args.maxSize:
maxSize = int(args.maxSize)
altAF = 0.25
if args.altAF:
altAF = float(args.altAF)

# Collect high-quality SVs
sv = dict()
Expand All @@ -48,11 +52,9 @@ def overlapValid(s1, e1, s2, e2, reciprocalOverlap=0.5, maxOffset=500):
rcRef = []
rcAlt = []
for call in record.samples:
#if (re.search(r"[Nn]ormal", call.sample) != None) and (call.called) and (call['FT'] == "PASS") and (call.gt_type == 0) and (call['DV'] <= 1):
if (re.search(r"[Nn]ormal", call.sample) != None) and (call.called) and (call['FT'] == "PASS") and (call.gt_type == 0) and (call['DV'] == 0):
if (re.search(r"[Nn]ormal", call.sample) != None) and (call.called) and (call.gt_type == 0) and (call['DV'] == 0):
rcRef.append(call['RC'])
#if (re.search(r"[Tt]umor", call.sample) != None) and (call.called) and (call['DV'] >= 2):
if (re.search(r"[Tt]umor", call.sample) != None) and (call.called) and (call['FT'] == "PASS") and (call.gt_type != 0):
if (re.search(r"[Tt]umor", call.sample) != None) and (call.called) and (call.gt_type != 0) and (call['DV'] >= 2) and (float(call['DV'])/float(call['DV']+call['DR'])>=altAF):
rcAlt.append(call['RC'])
if (len(rcRef) > 0) and (len(rcAlt) > 0) and (record.INFO['SVLEN'] >= minSize) and (record.INFO['SVLEN'] <= maxSize):
rdRatio = numpy.median(rcAlt)/numpy.median(rcRef)
Expand Down

0 comments on commit ff02f20

Please sign in to comment.