From 316439cfeca3e461af5b9dabc2e00d68da08419b Mon Sep 17 00:00:00 2001 From: Chen Tong Date: Fri, 24 Nov 2023 11:51:15 +0800 Subject: [PATCH] =?UTF-8?q?set=20label/chr=20size=20in=20layout=20file?= =?UTF-8?q?=EF=BC=9Badd=20genelabel=20rotation=20parameter=20(customize=20?= =?UTF-8?q?x=20and=20y=20for=20rotation=20with=20angle=200)=20(#608)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add ignore zero anchor parameter for skip no matches in batch search * ignore blank line in bed * set label/chr size in layout file * add genelabel rotation (customize x and y for rotation with angle 0) --- jcvi/graphics/synteny.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/jcvi/graphics/synteny.py b/jcvi/graphics/synteny.py index 5df591af..bb209cdc 100644 --- a/jcvi/graphics/synteny.py +++ b/jcvi/graphics/synteny.py @@ -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): @@ -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, @@ -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", @@ -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: @@ -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, @@ -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,