From 574a369a76adf5274808b65846396572618fc468 Mon Sep 17 00:00:00 2001 From: e-sollier Date: Thu, 22 Feb 2024 11:18:12 +0100 Subject: [PATCH] Improve chr label positition for circos plots --- figeno/figeno.py | 10 +++++----- figeno/track_chr.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/figeno/figeno.py b/figeno/figeno.py index 14d80de..9d62416 100644 --- a/figeno/figeno.py +++ b/figeno/figeno.py @@ -138,7 +138,7 @@ def __init__(self,config=None,config_file=None,reference=None,genes_file=None,ch t["genes_file"] = self.genes_file self.tracks_list.append(ase_track(**t)) else: - pass + print("WARNING: unrecognized track type: "+str(t)) self.figure_layout = config["general"]["layout"] self.output = None @@ -256,7 +256,7 @@ def draw_horizontal(self,file,width=183,dpi=150,transparent=False): current_height+=t.height+t.margin_above plt.axis('off') #fig.savefig(outfile,bbox_inches="tight",pad_inches=0.0,dpi=dpi) - plt.tight_layout(pad=0) + plt.tight_layout(pad=0.1) fig.savefig(file,dpi=dpi,transparent=transparent) plt.cla() plt.clf() @@ -292,7 +292,7 @@ def draw_stacked(self,file,width=183,dpi=150,transparent=False): current_height+=t.height+t.margin_above plt.axis('off') #fig.savefig(outfile,bbox_inches="tight",pad_inches=0.0,dpi=dpi) - plt.tight_layout(pad=0) + plt.tight_layout(pad=0.1) fig.savefig(file,dpi=dpi,transparent=transparent) plt.cla() plt.clf() @@ -337,7 +337,7 @@ def draw_symmetrical(self,file,width=183,dpi=150,transparent=False): current_height+=t.height plt.axis('off') - plt.tight_layout(pad=0) + plt.tight_layout(pad=0.1) fig.savefig(file,dpi=dpi,transparent=transparent) plt.cla() plt.clf() @@ -383,7 +383,7 @@ def draw_circular(self,file,width=183,dpi=150,transparent=False): plt.axis('off') ax.set_rmin(0) ax.set_rmax(current_r) - plt.tight_layout(pad=0) + plt.tight_layout(pad=0.1) fig.savefig(file,dpi=dpi,transparent=transparent) plt.cla() plt.clf() diff --git a/figeno/track_chr.py b/figeno/track_chr.py index 4418258..29e918a 100644 --- a/figeno/track_chr.py +++ b/figeno/track_chr.py @@ -289,10 +289,10 @@ def draw_region_circos(self,region,box): # label the region (need to rotate the text) rotation_text,halign,valign = compute_rotation_text((box["left"]+box["right"])/2) - r_text = r_rec+(box["top"]-box["bottom"])*0.1 - - box["ax"].text((box["left"]+box["right"])/2,r_text,region.chr,rotation=rotation_text,verticalalignment=valign,horizontalalignment=halign,fontsize=22*self.fontscale) + r_text = r_rec+(box["top"]-box["bottom"])*0.4 + #box["ax"].text((box["left"]+box["right"])/2,r_text,region.chr,rotation=rotation_text,verticalalignment=valign,horizontalalignment=halign,fontsize=22*self.fontscale) + box["ax"].text((box["left"]+box["right"])/2,r_text,region.chr,rotation=rotation_text,verticalalignment="center",horizontalalignment="center",fontsize=22*self.fontscale) #,bbox=dict(facecolor='red', alpha=0.4, edgecolor='black') def get_highlights_offsets(self):