Skip to content

Order extant genes by genomic coordinates and fix edge orientation - #46

Merged
alpae merged 2 commits into
DessimozLab:mainfrom
alpae:fix-extant-gene-order
Oct 19, 2026
Merged

alpae merged 2 commits into
DessimozLab:mainfrom
alpae:fix-extant-gene-order

Conversation

@alpae

@alpae alpae commented Oct 19, 2026

Copy link
Copy Markdown
Member

Fixes #40 (part of #43).

1. Extant genes are now ordered by genomic coordinates.
The extant synteny graphs linked consecutive genes in GFF file order, but GFF files are not necessarily sorted. Genes are now sorted by contig (contigs keep the order of their first appearance in the GFF), start and end before they are linked.

2. The orientation of extant edges uses the correct strand.
It used the strand of the previous gene in the GFF (gene_keys[i-1]), which is a skipped gene if a gene missing from the orthoXML lies in between. It now uses the strand of the previous linked gene.

Effect on results

This changes the inferred ancestral graphs whenever a GFF is not sorted, so the version is bumped to 0.1.11.

The GFFs in test_data are not sorted. In CALJA.gff, for example, all 1,110 genes are on chromosome 12, but stretches near 3, 28, 43, 63, 71 and 106 Mb are interleaved: 975 of the 1,109 steps between consecutive gene lines jump backwards or more than 1 Mb forwards (9 gaps > 1 Mb in sorted order). The first gene line, ENSCJAG00000042835.2 at 12:28,070,673, was followed by a gene at 2,976,794; its real neighbors are 3, 5, 8, 11, … lines further down, and its upstream neighbors are at the end of the file.

Ancestral edges summed over all levels, test_data run with --orient_edges:

main this PR shared
bottom-up 10,580 7,313 5,291
top-down 6,059 6,189 4,451
linearized 6,054 6,081 4,419

About 27% of the linearized ancestral edges change. The top-down phase now keeps 85% of the bottom-up edges, compared to 57% before, as far fewer spurious extant adjacencies are propagated. The ancestral edge checked by test_known_ancestral_adjacency is still inferred.

Not changed

The parser still assigns CDS lines to the gene line directly above them in the file (the Parent attribute is not used), so GFFs that do not list each gene's CDSs right after it are still misread. For nested or overlapping genes, sorting by start places a nested gene right after the gene containing it.

Tests: removed the xfail markers of test_unsorted_gff, test_interleaved_contigs and test_orientation_ignores_skipped_gene.

alpae added 2 commits October 19, 2026 13:57
The extant synteny graphs linked genes in GFF file order, but GFFs are
not necessarily sorted. In the test_data GFFs, for example, genes from
regions tens of Mb apart are interleaved, so genes were linked to genes
far away on the chromosome. Genes are now sorted by contig (in order of
first appearance in the GFF), start and end before they are linked.

The orientation of an extant edge used the strand of the previous gene
in the GFF, which is a skipped gene if a gene missing from the orthoXML
lies in between. It now uses the strand of the previous linked gene.

This changes the inferred ancestral graphs for unsorted GFFs.

Fixes DessimozLab#40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes address the reported defects with regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes extant synteny graph construction by using genomic order and the correct linked gene’s strand.

Changes:

  • Sort genes by contig and coordinates before linking them.
  • Use the previous linked gene’s strand for edge orientation.
  • Enable three regression tests and bump the version to 0.1.11.
File Description
uv.lock Updates the locked project version.
tests/​test_extant_graphs.py Removes expected-failure markers from three regression tests.
pyproject.toml Bumps the project version to 0.1.11.
edgehog/​init_extant_synteny_graphs.py Corrects gene ordering and edge orientation.

Review effort: Balanced

@alpae
alpae merged commit 4a5b255 into DessimozLab:main Oct 19, 2026
6 checks passed
@alpae
alpae deleted the fix-extant-gene-order branch October 19, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extant graphs: gene order taken from GFF file order, and orientation can use a skipped gene's strand

2 participants