tanghaibao / jcvi

Python library to facilitate genome assembly, annotation, and comparative genomics
BSD 2-Clause "Simplified" License
712 stars 185 forks source link

Miscellaneous chromosome sorting #588

Closed cutykaka closed 10 months ago

cutykaka commented 10 months ago

Hello. I've been finding the jcvi program extremely useful. Currently, I am using python -m jcvi.graphics.chromosome for Miscellaneous plotting. However, if there are more than 10 chromosomes, they don't get arranged in the order 1, 2, 3,..., 11, 12 but rather 1, 11, 12, 2, 3, 4, 5,... It seems like this issue occurs due to Python's sorting behavior.

Do I need to modify the jcvi/graphics/chromosome.py code to address this, or is there an existing setting option for this?

Thank you.

tanghaibao commented 10 months ago

@cutykaka

I think this is a good idea and modified the sorted function to use natsorted instead, in https://github.com/tanghaibao/jcvi/commit/a60413503059a16f92697a81b6967fe5ee29f414.

Let me know if this helps.

cutykaka commented 10 months ago

I've confirmed that it's working well. However, the problem is that while karyotype sorting is done by chromosome, when reading the information from the BED file, it aligns according to the chromosome array before applying the natsorted function. This creates an issue.

Thank you.

cutykaka commented 10 months ago

cool! It's solved. Thank you :)