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

Overlaping arrows #42

Open
ghutinet opened this issue Sep 23, 2020 · 8 comments
Open

Overlaping arrows #42

ghutinet opened this issue Sep 23, 2020 · 8 comments

Comments

@ghutinet
Copy link

Great tool!

The only thing I couldn't figure is if you want all your gene arrows on the same line with overlapping arrows.
I didn't find any option that would allow me to do so. Is there any? If yes would it draw the tip of the arrow on top the next gene arrow or on the bottom?

Thank you

@FruityPerdix
Copy link

Hey,
I was having the same issue. In the end I used illustrator to align the arrows to the line. This kind of defeats the point.
I'm posting this to emphasize that there is more interest for this option.

Other than that I enjoy the library!

@Zulko
Copy link
Member

Zulko commented Sep 23, 2020

@ghutinet @FruityPerdix there may be a trick to do that I am not 100% sure I understand what the expected result is, do you have a screenshot/schema?

@FruityPerdix
Copy link

This is what would be ideal:

overlapping_arrows

@Zulko
Copy link
Member

Zulko commented Sep 24, 2020

This can be done by setting the record's feature_level_height to 0, which can be done at record creation of afterwards. Here is a minimal example:

from dna_features_viewer import GraphicFeature, GraphicRecord
import numpy as np

record = GraphicRecord(sequence_length=1000, features=[
    GraphicFeature(
        start=50 * i + np.random.randint(-20, 20),
        end=50 * i + np.random.randint(30, 70),
        strand= [-1, 1][i % 2],
        color=["limegreen", "yellow", "cyan"][i % 3],
    )
    for i in range(20)
])
record.feature_level_height = 0  # <=====
ax, _ = record.plot(figure_width=10);

Selection_641
Selection_642

@ghutinet
Copy link
Author

Thanks, that works to align the arrows! However the annotation heights are not updated and stay at weird places:
phiST

@avery-r
Copy link

avery-r commented Nov 11, 2021

I'm curious to know if there was ever a fix for this issue. I had to mess around with the label font size and labels_spacing settings to find a combination of values that resulted in all labels being attached to lines.

@veghp
Copy link
Member

veghp commented Nov 23, 2021

This problem is a bit complicated and may need refactoring, but redefining the below function before plotting at least connects the boxes until a proper solution is implemented:

def new_determine_annotation_height(levels):
    return 1
record.determine_annotation_height = new_determine_annotation_height

example

@ZongzhiWu
Copy link

How about circular genomes?

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

No branches or pull requests

6 participants