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

Fix: TSS and TTS now is corrected and documented #345

Merged
merged 3 commits into from
Oct 31, 2024
Merged
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
33 changes: 27 additions & 6 deletions sqanti3_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,33 @@ def calc_exon_overlap(query_exons, ref_exons):
return sum(q_bases.values())

def get_diff_tss_tts(trec, ref):
# Calculating differences between transcript start sites (TSS) and
# Trasncript termination site (TTS) of two transcripts
if trec.strand == '+':
diff_tss = trec.txStart - ref.txStart
diff_tts = trec.txEnd - ref.txEnd
# In positive (+) strand transcripts:
# TSS is calculated as reference start - transcript start
# TTS is calculated as transcript end - reference end
# This way, TSS < 0 means the transcript is shortened, and
# TSS > 0 means that transcript is elongated. Similarly, a
# TTS < 0 means that transcript is shortened, and a TTS > 0
# means that the transcript is elongated
diff_tss = ref.txStart - trec.txStart
diff_tts = trec.txEnd - ref.txEnd
else:
# In negative (-) strand transcripts:
# The transcripts in negative strands are loaded with trans.start = end
# and trans.end = start, to assure that trans.end > trans.start
# regardless of the transcript. TTS and TSS are calculated with
# the same formula, but taking the loading fact into account,
# The formulas are inverted
# TTS is ref start - transcript start
# TSS is transcript end - treference end
# Being consistent in that TSS < 0 means the transcript is shortened, and
# TSS > 0 means that transcript is elongated. Similarly, a
# TTS < 0 means that transcript is shortened, and a TTS > 0
# means that the transcript is elongated
diff_tts = ref.txStart - trec.txStart
diff_tss = ref.txEnd - trec.txEnd
diff_tss = trec.txEnd - ref.txEnd
return diff_tss, diff_tts


Expand All @@ -899,7 +920,7 @@ def get_gene_diff_tss_tts(isoform_hit):
nearest_start_diff, nearest_end_diff = float('inf'), float('inf')
for ref_gene in isoform_hit.genes:
for x in start_ends_by_gene[ref_gene]['begin']:
d = trec.txStart - x
d = x - trec.txStart
if abs(d) < abs(nearest_start_diff):
nearest_start_diff = d
for x in start_ends_by_gene[ref_gene]['end']:
Expand All @@ -911,8 +932,8 @@ def get_gene_diff_tss_tts(isoform_hit):
isoform_hit.tss_gene_diff = nearest_start_diff if nearest_start_diff!=float('inf') else 'NA'
isoform_hit.tts_gene_diff = nearest_end_diff if nearest_end_diff!=float('inf') else 'NA'
else:
isoform_hit.tss_gene_diff = -nearest_end_diff if nearest_start_diff!=float('inf') else 'NA'
isoform_hit.tts_gene_diff = -nearest_start_diff if nearest_end_diff!=float('inf') else 'NA'
isoform_hit.tss_gene_diff = nearest_end_diff if nearest_start_diff!=float('inf') else 'NA'
isoform_hit.tts_gene_diff = nearest_start_diff if nearest_end_diff!=float('inf') else 'NA'

def categorize_incomplete_matches(trec, ref):
"""
Expand Down
142 changes: 0 additions & 142 deletions sqanti3_wrapper.conf

This file was deleted.

Loading