-
Notifications
You must be signed in to change notification settings - Fork 5
Coral #205
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
Open
robert-a-forsyth
wants to merge
38
commits into
dev
Choose a base branch
from
coral
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Coral #205
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
59c2216
make passing variants the only form pushed through to downstream anal…
robert-a-forsyth c596e1b
fixes to the filtering
robert-a-forsyth 9a1e8e6
testing
robert-a-forsyth 938f084
fix bugs
robert-a-forsyth 5b38dcf
bump wakhan (bug)
robert-a-forsyth 1f93364
Merge remote-tracking branch 'origin/dev' into variant_filter
robert-a-forsyth da99d0b
Split multi-allelics before intersection, harden the consensus channe…
robert-a-forsyth b646c20
Adjudicate the tumour-only germline arm with DeepSomatic's verdict
robert-a-forsyth 33bb9b2
Preserve the caller's FILTER through VCFTAG so the PASS filter still …
robert-a-forsyth 33a631b
Make the VCFTAG test runnable
robert-a-forsyth 825af15
Fold STANDARDIZE_AF into BCFTOOLS_ANNOTATE
robert-a-forsyth d4401a4
Drop a duplicated CLAIR3 argument and correct a false ordering comment
robert-a-forsyth d3b4581
Regenerate snapshots for the germline/somatic tagging processes
robert-a-forsyth 50d887a
Merge remote-tracking branch 'origin/dev' into variant_filter
robert-a-forsyth 25a0191
fix report clog
robert-a-forsyth 0a3024a
Fill in the PR number on this branch's changelog entries
robert-a-forsyth 2d4e9ce
Merge remote-tracking branch 'origin/dev' into variant_filter
robert-a-forsyth d5e610e
Satisfy the pre-commit hooks: call the report slot closure explicitly
robert-a-forsyth 1376557
Add ecDNA analysis: CoRAL reconstruction and AmpliconClassifier
robert-a-forsyth 001926c
fixes ecDNA subworkflow
robert-a-forsyth 27728f8
Move the INFO/SOMATIC filter of local BCFTOOLS_VIEW into ext.args
robert-a-forsyth c691a0c
Leave FILTER untouched in VCFTAG
robert-a-forsyth 75036a0
Prefilter DS_VERDICT_QUERY to the non-PASS/RefCall DeepSomatic rows
robert-a-forsyth 18023f2
Rejoin split multi-allelics after the caller consensus
robert-a-forsyth 6a3e297
Join ASCAT and Wakhan report files instead of counting with groupKey
robert-a-forsyth d653bcb
Inline the PASS filter as BCFTOOLS_VIEW aliases at each caller
robert-a-forsyth c91a23e
Add VCFTAG meta.yml and fix var_keep defaults in usage.md
robert-a-forsyth 5fae932
Allow deepvariant without deepsomatic; skip the verdict transfer then
robert-a-forsyth 00a9312
Cut long comments, sample numbers and CHANGELOG write-ups to one or t…
robert-a-forsyth ff88896
Regenerate pipeline snapshots after the review fixes
robert-a-forsyth 219aaaf
Merge remote-tracking branch 'origin/dev' into coral
ljwharbers 7692333
Merge dev into variant_filter
ljwharbers 46e9346
Phase only alt somatic records, without germline records at their pos…
robert-a-forsyth 97801ff
Keep one caller's record per position in the 'all' caller union
robert-a-forsyth cadbdee
Assert record contents of the phased VCFs in the pipeline tests
robert-a-forsyth 24404b8
Warn when tumour-only DeepVariant calls run without DeepSomatic's ver…
robert-a-forsyth 1982724
Regenerate pipeline snapshots after the review fixes
robert-a-forsyth 9ce6a8a
Merge remote-tracking branch 'origin/variant_filter' into coral
robert-a-forsyth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/usr/bin/env python3 | ||
| """Convert ASCAT's cnvs.txt into the headerless BED CoRAL's --cn-seg expects. | ||
|
|
||
| CoRAL reads total copy number from the last column and builds chromosome sizes from | ||
| the BAM header, so contigs are respelled to match the reference (chr1 vs 1). | ||
| """ | ||
| import argparse | ||
| import sys | ||
|
|
||
| REQUIRED = ('chr', 'startpos', 'endpos', 'nMajor', 'nMinor') | ||
|
|
||
|
|
||
| def fai_contigs(path): | ||
| if not path: | ||
| return [] | ||
| with open(path) as fp: | ||
| return [line.split('\t', 1)[0] for line in fp if line.strip()] | ||
|
|
||
|
|
||
| def spell_like_reference(chrom, contigs): | ||
| """ASCAT's '1' becomes 'chr1' when that is what the reference calls it, and the reverse.""" | ||
| if not contigs or chrom in contigs: | ||
| return chrom | ||
| if chrom.startswith('chr') and chrom[3:] in contigs: | ||
| return chrom[3:] | ||
| if 'chr' + chrom in contigs: | ||
| return 'chr' + chrom | ||
| return chrom | ||
|
|
||
|
|
||
| def sort_key(chrom): | ||
| """Natural contig order: 1-22, then X, Y, then anything else alphabetically.""" | ||
| bare = chrom[3:] if chrom.startswith('chr') else chrom | ||
| if bare.isdigit(): | ||
| return (0, int(bare), '') | ||
| if bare in ('X', 'Y'): | ||
| return (1, 'XY'.index(bare), '') | ||
| return (2, 0, bare) | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | ||
| parser.add_argument('--cnvs', required=True, help="ASCAT <sample>.cnvs.txt") | ||
| parser.add_argument('--fai', help="Reference .fai, to respell contigs to match the BAM") | ||
| parser.add_argument('--output', required=True, help="BED4 written for CoRAL --cn-seg") | ||
| args = parser.parse_args() | ||
|
|
||
| contigs = fai_contigs(args.fai) | ||
|
|
||
| with open(args.cnvs) as fp: | ||
| header = fp.readline().rstrip('\n').split('\t') | ||
| missing = [c for c in REQUIRED if c not in header] | ||
| if missing: | ||
| sys.exit(f"ERROR: {args.cnvs} is missing required columns: {', '.join(missing)}") | ||
| idx = {c: header.index(c) for c in REQUIRED} | ||
|
|
||
| rows, dropped = [], 0 | ||
| for line in fp: | ||
| if not line.strip(): | ||
| continue | ||
| fields = line.rstrip('\n').split('\t') | ||
| start, end = int(fields[idx['startpos']]), int(fields[idx['endpos']]) | ||
| # CoRAL's segment parser rejects these, so drop them here with a count | ||
| if start >= end: | ||
| dropped += 1 | ||
| continue | ||
| total_cn = round(float(fields[idx['nMajor']])) + round(float(fields[idx['nMinor']])) | ||
| rows.append((spell_like_reference(fields[idx['chr']], contigs), start, end, total_cn)) | ||
|
|
||
| if dropped: | ||
| print(f"WARNING: dropped {dropped} segments with start >= end", file=sys.stderr) | ||
|
|
||
| rows.sort(key=lambda r: (sort_key(r[0]), r[1])) | ||
| with open(args.output, 'w') as out: | ||
| for chrom, start, end, total_cn in rows: | ||
| out.write(f"{chrom}\t{start}\t{end}\t{total_cn}\n") | ||
|
|
||
| if not rows: | ||
| print(f"WARNING: {args.output} is empty; CoRAL will find no seeds", file=sys.stderr) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#XXX→#205(also on the two lines above). The claim about covering the empty-seed branch doesn't hold: the CORAL_SEED stub always writes a non-empty seed, and none of the three ECDNA tests forces an empty one.