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

set label/chr size in layout file;add genelabel rotation parameter (customize x and y for rotation with angle 0) #608

Merged
merged 9 commits into from
Nov 24, 2023
20 changes: 16 additions & 4 deletions jcvi/graphics/synteny.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def __init__(self, row, delimiter=","):
self.label = args[7].strip()
else:
self.label = None

if len(args) > 8:
self.label_fontsize = float(args[8])
else:
self.label_fontsize = 10

class Layout(AbstractLayout):
def __init__(self, filename, delimiter=",", seed: Optional[int] = None):
Expand Down Expand Up @@ -193,6 +196,7 @@ def __init__(
loc_label=True,
gene_labels: Optional[set] = None,
genelabelsize=0,
genelabelrotation=25,
pad=0.05,
vpad=0.015,
extra_features=None,
Expand Down Expand Up @@ -277,7 +281,7 @@ def __init__(
y + height / 2 + genelabelsize * vpad / 3,
markup(gene_name),
size=genelabelsize,
rotation=25,
rotation=genelabelrotation,
ha="left",
va="center",
color="lightslategray",
Expand Down Expand Up @@ -352,13 +356,13 @@ def __init__(
loc_label = label if loc_label else None
if chr_label:
if loc_label:
ax.text(lx, ly + vpad, chr_label, color=layout.color, **kwargs)
ax.text(lx, ly + vpad, chr_label, size=layout.label_fontsize, color=layout.color, **kwargs)
ax.text(
lx,
ly - vpad,
loc_label,
color="lightslategrey",
size=10,
size=layout.label_fontsize,
**kwargs,
)
else:
Expand Down Expand Up @@ -599,6 +603,13 @@ def main():
+ "However, plot may appear visually crowded. "
+ "Reasonably good values are 2 to 6 [Default: disabled]",
)
p.add_option(
"--genelabelrotation",
default=25,
type="int",
help="Rotate gene labels at this angle (anti-clockwise), useful for debugging. "
+ "[Default: 25]",
)
p.add_option(
"--scalebar",
default=False,
Expand Down Expand Up @@ -647,6 +658,7 @@ def main():
extra_features=opts.extra,
gene_labels=gene_labels,
genelabelsize=opts.genelabelsize,
genelabelrotation=opts.genelabelrotation,
scalebar=opts.scalebar,
shadestyle=opts.shadestyle,
glyphstyle=opts.glyphstyle,
Expand Down