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: add track offset for segment separators #68

Merged
merged 1 commit into from
Dec 1, 2024

Conversation

msdyachkova
Copy link
Contributor

Fix segment separator positioning when track offset is not 0 (track_align_type is not "left")

@moshi4
Copy link
Owner

moshi4 commented Dec 1, 2024

Hi @msdyachkova,

Thanks for the bug fix PR. I'll merge it soon.


Code for checking bug fix

from pygenomeviz import GenomeViz
from pygenomeviz.parser import Genbank
from pygenomeviz.utils import load_example_genbank_dataset, ColorCycler
ColorCycler.set_cmap("tab10")

gbk_files = load_example_genbank_dataset("saccharomyces")
gbk_list = list(map(Genbank, gbk_files))

gv = GenomeViz(fig_track_height=0.7, feature_track_ratio=0.15, track_align_type="center")
gv.set_scale_bar(ymargin=2.0)

for gbk in gbk_list:
    color = ColorCycler()
    track = gv.add_feature_track(gbk.name, gbk.get_seqid2size(), space=0.01, label_kws=dict(color=color))
    track.set_label(track.name.replace("_", "\n"))
    for segment in track.segments:
        segment.add_feature(segment.start, segment.end, plotstyle="bigrbox", fc=color, lw=0.5)
    track.set_segment_sep()

gv.savefig("result.png")

Before

before_result.png

After

after_result.png

@moshi4 moshi4 mentioned this pull request Dec 1, 2024
@moshi4 moshi4 merged commit 3e98fc1 into moshi4:main Dec 1, 2024
8 checks passed
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.

2 participants