-
Notifications
You must be signed in to change notification settings - Fork 4
Further information on r2d liftover
pre-mRNA edited this page Jun 24, 2024
·
2 revisions
R2Dtool liftover enables the rapid conversion from coordinates mapped in transcriptomic space, to coordinates mapped in genomic space.
We provide pseudocode for the convert_transcriptomic_to_genomic_coordinates
function that is invoked by the r2d liftover
command:
Algorithm: convert_transcriptomic_to_genomic_coordinates
Inputs:
- site_fields: array of strings containing transcriptomic information
- annotations: hashmap of transcript annotations
- has_version: boolean indicating if transcript IDs include version numbers
Output:
- String containing genomic coordinates or None if conversion fails
1. If length of site_fields < 4:
Return None
2. transcript_id_with_version ← site_fields[0]
3. If has_version:
transcript_id ← transcript_id_with_version
Else:
transcript_id ← Split transcript_id_with_version by '.' and take first part
4. position ← Parse site_fields[1] as integer
5. current_position ← 0
6. If transcript_id exists in annotations:
transcript ← annotations[transcript_id]
7. Sort exons of transcript:
If transcript.strand = '-':
Sort exons in descending order by start position
Else:
Sort exons in ascending order by start position
8. For each exon in sorted exons:
exon_length ← exon.end - exon.start + 1
9. If current_position + exon_length > position:
If transcript.strand = '+':
genomic_position ← position - current_position + exon.start - 1
Else:
genomic_position ← exon.end - (position - current_position) - 1
10. chrom ← transcript.chromosome
genomic_strand ← transcript.strand
additional_columns ← Join site_fields[1:] with tab separator
11. Return formatted string:
"{chrom}\t{genomic_position}\t{genomic_position + 1}\t\t\t{genomic_strand}\t{transcript_id_with_version}\t{additional_columns}"
12. current_position ← current_position + exon_length
13. Print warning: "No associated transcripts found for site '{transcript_id}'"
14. Return None
Original source code for the liftover function is available at https://github.com/comprna/R2Dtool/blob/main/src/liftover.rs