-
Notifications
You must be signed in to change notification settings - Fork 12
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
Prepend chromosomes with chr to match the SAM/BAM files. #132
Open
roryk
wants to merge
1
commit into
Clinical-Genomics:master
Choose a base branch
from
roryk:master
base: master
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
Changes from all commits
Commits
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 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 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 |
---|---|---|
|
@@ -22,17 +22,15 @@ | |
) | ||
from ..utils import bed_to_interval, split, validate_bed_format | ||
|
||
|
||
def annotate_bed_stream(bed_stream, bam_path, cutoff=10, extension=0, | ||
contig_prefix='', bp_threshold=17000): | ||
"""Annotate all intervals from a BED-file stream. | ||
|
||
Yields tuple data for each interval with calculated coverage and | ||
completeness. | ||
|
||
def apply_bed_stream(bed_stream, bam_path, fn, extension=0, | ||
contig_prefix='', bp_threshold=17000): | ||
"""Maps a function to all intervals of a BED stream | ||
Args: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be awesome with a simple description of the |
||
bed_stream (sequence): usually a BED-file handle to read from | ||
bam_path (str): path to BAM-file | ||
fn: function that takes a list of intervals and read depths | ||
and computes a summary statistic over them. See | ||
annotator.stages.calculate_metrics for an example. | ||
cutoff (int, optional): threshold for completeness calculation, | ||
defaults to 10 | ||
extension (int, optional): number of bases to extend each interval | ||
|
@@ -41,10 +39,6 @@ def annotate_bed_stream(bed_stream, bam_path, cutoff=10, extension=0, | |
defaults to empty string | ||
bp_threshold (int, optional): optimization threshold for reading | ||
BAM-file in chunks, default to 17000 | ||
|
||
Yields: | ||
tuple: :class:`chanjo.BaseInterval`, coverage (float), and | ||
completeness (float) | ||
""" | ||
# setup: connect to BAM-file | ||
bam = BamFile(bam_path) | ||
|
@@ -62,5 +56,35 @@ def annotate_bed_stream(bed_stream, bam_path, cutoff=10, extension=0, | |
group_intervals(bp_threshold=bp_threshold), # group by threshold | ||
map(process_interval_group(bam)), # read coverage | ||
concat, # flatten list of lists | ||
map(calculate_metrics(threshold=cutoff)) # calculate cov./compl. | ||
map(fn) # map provided function | ||
) | ||
|
||
|
||
def annotate_bed_stream(bed_stream, bam_path, cutoff=10, extension=0, | ||
contig_prefix='', bp_threshold=17000): | ||
"""Annotate all intervals from a BED-file stream. | ||
|
||
Yields tuple data for each interval with calculated coverage and | ||
completeness. | ||
|
||
Args: | ||
bed_stream (sequence): usually a BED-file handle to read from | ||
bam_path (str): path to BAM-file | ||
cutoff (int, optional): threshold for completeness calculation, | ||
defaults to 10 | ||
extension (int, optional): number of bases to extend each interval | ||
with (+/-), defaults to 0 | ||
contig_prefix (str, optional): rename contigs by prefixing, | ||
defaults to empty string | ||
bp_threshold (int, optional): optimization threshold for reading | ||
BAM-file in chunks, default to 17000 | ||
|
||
Yields: | ||
tuple: :class:`chanjo.BaseInterval`, coverage (float), and | ||
completeness (float) | ||
""" | ||
# setup: connect to BAM-file | ||
fn = calculate_metrics(threshold=cutoff) | ||
|
||
return apply_bed_stream(bed_stream, bam_path, fn, extension, | ||
contig_prefix, bp_threshold) |
This file contains 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#chromosome nc_accession gene gene_id ccds_id ccds_status cds_strand cds_from cds_to cds_locations match_type | ||
1 NC_000001.8 LINC00115 79854 CCDS1.1 Withdrawn - 801942 802433 [801942-802433] Identical | ||
1 NC_000001.10 SAMD11 148398 CCDS2.2 Public + 11 35 [11-18, 25-30, 32-35] Identical | ||
22 NC_000022.10 RFPL2 10739 CCDS54521.1 Public - 32586758 32589173 [32586758-32587338, 32588888-32589173] Identical | ||
22 NC_000022.10 RFPL2 10739 CCDS46694.1 Public - 32586758 32589260 [32586758-32587338, 32588888-32589260] Identical | ||
X NC_000023.10 TRO 7216 CCDS59529.1 Public + 54951423 54957452 [54951423-54951500, 54952024-54952115, 54952842-54952921, 54953015-54953057, 54953475-54953537, 54954099-54954213, 54955035-54957452] Identical | ||
Y NC_000024.9 TSPY8 728403 CCDS59533.1 Public + 9195451 9198013 [9195451-9195936, 9196544-9196621, 9196750-9196861, 9196963-9197108, 9197215-9197296, 9197991-9198013] Identical | ||
chr1 NC_000001.8 LINC00115 79854 CCDS1.1 Withdrawn - 801942 802433 [801942-802433] Identical | ||
chr1 NC_000001.10 SAMD11 148398 CCDS2.2 Public + 11 35 [11-18, 25-30, 32-35] Identical | ||
chr22 NC_000022.10 RFPL2 10739 CCDS54521.1 Public - 32586758 32589173 [32586758-32587338, 32588888-32589173] Identical | ||
chr22 NC_000022.10 RFPL2 10739 CCDS46694.1 Public - 32586758 32589260 [32586758-32587338, 32588888-32589260] Identical | ||
chrX NC_000023.10 TRO 7216 CCDS59529.1 Public + 54951423 54957452 [54951423-54951500, 54952024-54952115, 54952842-54952921, 54953015-54953057, 54953475-54953537, 54954099-54954213, 54955035-54957452] Identical | ||
chrY NC_000024.9 TSPY8 728403 CCDS59533.1 Public + 9195451 9198013 [9195451-9195936, 9196544-9196621, 9196750-9196861, 9196963-9197108, 9197215-9197296, 9197991-9198013] Identical |
This file contains 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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
1 11 18 1-11-18 0 + CCDS2.2 SAMD11 | ||
1 25 30 1-25-30 0 + CCDS2.2 SAMD11 | ||
1 32 35 1-32-35 0 + CCDS2.2 SAMD11 | ||
22 32586758 32587338 22-32586758-32587338 0 - CCDS54521.1,CCDS46694.1 RFPL2,RFPL2 | ||
22 32588888 32589260 22-32588888-32589260 0 - CCDS46694.1 RFPL2 | ||
22 32588888 32589173 22-32588888-32589173 0 - CCDS54521.1 RFPL2 | ||
X 54951423 54951500 X-54951423-54951500 0 + X-CCDS59529.1 X-TRO | ||
X 54952024 54952115 X-54952024-54952115 0 + X-CCDS59529.1 X-TRO | ||
X 54952842 54952921 X-54952842-54952921 0 + X-CCDS59529.1 X-TRO | ||
X 54953015 54953057 X-54953015-54953057 0 + X-CCDS59529.1 X-TRO | ||
X 54953475 54953537 X-54953475-54953537 0 + X-CCDS59529.1 X-TRO | ||
X 54954099 54954213 X-54954099-54954213 0 + X-CCDS59529.1 X-TRO | ||
X 54955035 54957452 X-54955035-54957452 0 + X-CCDS59529.1 X-TRO | ||
Y 9195451 9195936 Y-9195451-9195936 0 + Y-CCDS59533.1 Y-TSPY8 | ||
Y 9196544 9196621 Y-9196544-9196621 0 + Y-CCDS59533.1 Y-TSPY8 | ||
Y 9196750 9196861 Y-9196750-9196861 0 + Y-CCDS59533.1 Y-TSPY8 | ||
Y 9196963 9197108 Y-9196963-9197108 0 + Y-CCDS59533.1 Y-TSPY8 | ||
Y 9197215 9197296 Y-9197215-9197296 0 + Y-CCDS59533.1 Y-TSPY8 | ||
Y 9197991 9198013 Y-9197991-9198013 0 + Y-CCDS59533.1 Y-TSPY8 | ||
chr1 11 18 1-11-18 0 + CCDS2.2 SAMD11 | ||
chr1 25 30 1-25-30 0 + CCDS2.2 SAMD11 | ||
chr1 32 35 1-32-35 0 + CCDS2.2 SAMD11 | ||
chr22 32586758 32587338 22-32586758-32587338 0 - CCDS54521.1,CCDS46694.1 RFPL2,RFPL2 | ||
chr22 32588888 32589260 22-32588888-32589260 0 - CCDS46694.1 RFPL2 | ||
chr22 32588888 32589173 22-32588888-32589173 0 - CCDS54521.1 RFPL2 | ||
chrX 54951423 54951500 X-54951423-54951500 0 + X-CCDS59529.1 X-TRO | ||
chrX 54952024 54952115 X-54952024-54952115 0 + X-CCDS59529.1 X-TRO | ||
chrX 54952842 54952921 X-54952842-54952921 0 + X-CCDS59529.1 X-TRO | ||
chrX 54953015 54953057 X-54953015-54953057 0 + X-CCDS59529.1 X-TRO | ||
chrX 54953475 54953537 X-54953475-54953537 0 + X-CCDS59529.1 X-TRO | ||
chrX 54954099 54954213 X-54954099-54954213 0 + X-CCDS59529.1 X-TRO | ||
chrX 54955035 54957452 X-54955035-54957452 0 + X-CCDS59529.1 X-TRO | ||
chrY 9195451 9195936 Y-9195451-9195936 0 + Y-CCDS59533.1 Y-TSPY8 | ||
chrY 9196544 9196621 Y-9196544-9196621 0 + Y-CCDS59533.1 Y-TSPY8 | ||
chrY 9196750 9196861 Y-9196750-9196861 0 + Y-CCDS59533.1 Y-TSPY8 | ||
chrY 9196963 9197108 Y-9196963-9197108 0 + Y-CCDS59533.1 Y-TSPY8 | ||
chrY 9197215 9197296 Y-9197215-9197296 0 + Y-CCDS59533.1 Y-TSPY8 | ||
chrY 9197991 9198013 Y-9197991-9198013 0 + Y-CCDS59533.1 Y-TSPY8 |
This file contains 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#{"group_id": null, "sample_id": "tiriwiro", "coverage_source": "/Users/robinandeer/Projects/clinical-genomics/qxt/bam/Sample_E2-QXT-prep2/sorted.bam", "cutoff": 10, "extension": 0} | ||
1 12 18 1-11-18 0 + CCDS2.2 SAMD11 0.0 0.0 | ||
1 26 30 1-25-30 0 + CCDS2.2 SAMD11 0.0 0.0 | ||
1 33 35 1-32-35 0 + CCDS2.2 SAMD11 0.0 0.0 | ||
22 32586759 32587338 22-32586758-32587338 0 - CCDS54521.1,CCDS46694.1 RFPL2,RFPL2 139.862068966 1.0 | ||
22 32588889 32589260 22-32588888-32589260 0 - CCDS46694.1 RFPL2 146.86827957 1.0 | ||
22 32588889 32589173 22-32588888-32589173 0 - CCDS54521.1 RFPL2 140.631578947 1.0 | ||
X 54951424 54951500 X-54951423-54951500 0 + X-CCDS59529.1 X-TRO 13.8961038961 1.0 | ||
X 54952025 54952115 X-54952024-54952115 0 + X-CCDS59529.1 X-TRO 81.5714285714 1.0 | ||
X 54952843 54952921 X-54952842-54952921 0 + X-CCDS59529.1 X-TRO 37.7974683544 1.0 | ||
X 54953016 54953057 X-54953015-54953057 0 + X-CCDS59529.1 X-TRO 13.0714285714 0.9523809523809523 | ||
X 54953476 54953537 X-54953475-54953537 0 + X-CCDS59529.1 X-TRO 19.5 1.0 | ||
X 54954100 54954213 X-54954099-54954213 0 + X-CCDS59529.1 X-TRO 23.5350877193 1.0 | ||
X 54955036 54957452 X-54955035-54957452 0 + X-CCDS59529.1 X-TRO 43.4224244932 1.0 | ||
Y 9195452 9195936 Y-9195451-9195936 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
Y 9196545 9196621 Y-9196544-9196621 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
Y 9196751 9196861 Y-9196750-9196861 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
Y 9196964 9197108 Y-9196963-9197108 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
Y 9197216 9197296 Y-9197215-9197296 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
Y 9197992 9198013 Y-9197991-9198013 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
chr1 12 18 1-11-18 0 + CCDS2.2 SAMD11 0.0 0.0 | ||
chr1 26 30 1-25-30 0 + CCDS2.2 SAMD11 0.0 0.0 | ||
chr1 33 35 1-32-35 0 + CCDS2.2 SAMD11 0.0 0.0 | ||
chr22 32586759 32587338 22-32586758-32587338 0 - CCDS54521.1,CCDS46694.1 RFPL2,RFPL2 139.862068966 1.0 | ||
chr22 32588889 32589260 22-32588888-32589260 0 - CCDS46694.1 RFPL2 146.86827957 1.0 | ||
chr22 32588889 32589173 22-32588888-32589173 0 - CCDS54521.1 RFPL2 140.631578947 1.0 | ||
chrX 54951424 54951500 X-54951423-54951500 0 + X-CCDS59529.1 X-TRO 13.8961038961 1.0 | ||
chrX 54952025 54952115 X-54952024-54952115 0 + X-CCDS59529.1 X-TRO 81.5714285714 1.0 | ||
chrX 54952843 54952921 X-54952842-54952921 0 + X-CCDS59529.1 X-TRO 37.7974683544 1.0 | ||
chrX 54953016 54953057 X-54953015-54953057 0 + X-CCDS59529.1 X-TRO 13.0714285714 0.9523809523809523 | ||
chrX 54953476 54953537 X-54953475-54953537 0 + X-CCDS59529.1 X-TRO 19.5 1.0 | ||
chrX 54954100 54954213 X-54954099-54954213 0 + X-CCDS59529.1 X-TRO 23.5350877193 1.0 | ||
chrX 54955036 54957452 X-54955035-54957452 0 + X-CCDS59529.1 X-TRO 43.4224244932 1.0 | ||
chrY 9195452 9195936 Y-9195451-9195936 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
chrY 9196545 9196621 Y-9196544-9196621 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
chrY 9196751 9196861 Y-9196750-9196861 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
chrY 9196964 9197108 Y-9196963-9197108 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
chrY 9197216 9197296 Y-9197215-9197296 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 | ||
chrY 9197992 9198013 Y-9197991-9198013 0 + Y-CCDS59533.1 Y-TSPY8 0.0 0.0 |
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.
This is a nice addition!