diff --git a/metaloci/plot/plot.py b/metaloci/plot/plot.py index a810ab0..4653609 100644 --- a/metaloci/plot/plot.py +++ b/metaloci/plot/plot.py @@ -447,6 +447,7 @@ def signal_bed( bed_data["start"].append(lmi_geometry.bin_start[point]) bed_data["end"].append(lmi_geometry.bin_end[point]) bed_data["bin"].append(point) + except: pass @@ -465,7 +466,7 @@ def signal_plot(mlobject: mlo.MetalociObject, lmi_geometry: pd.DataFrame, metalo for p in metalocis: - plt.axvline(x=p, color="red", linestyle=":", lw=1.5) + plt.axvline(x=p, color="red", linestyle=":", lw=1, zorder=0, alpha=0.3) plt.axvline(x=mlobject.poi, color="lime", linestyle="--", lw=1.5) @@ -479,7 +480,7 @@ def signal_plot(mlobject: mlo.MetalociObject, lmi_geometry: pd.DataFrame, metalo sns.despine(top=True, right=True, left=False, bottom=True, offset=None, trim=False) - return sig_plt + return sig_plt, g def place_composite(new_PI, ifile, ifactor, ixloc, iyloc): diff --git a/metaloci/tools/figure.py b/metaloci/tools/figure.py index a3d148d..2a61c07 100644 --- a/metaloci/tools/figure.py +++ b/metaloci/tools/figure.py @@ -274,7 +274,7 @@ def run(opts): # selmetaloci = [] - sig_plt = plot.signal_plot(mlobject, merged_lmi_geometry, selmetaloci, bins, coords_b) + sig_plt, ax = plot.signal_plot(mlobject, merged_lmi_geometry, selmetaloci, bins, coords_b) sig_plt.savefig(f"{plot_filename}_signal.pdf", **plot_opt) sig_plt.savefig(f"{plot_filename}_signal.png", **plot_opt) plt.close() @@ -312,10 +312,18 @@ def run(opts): maxx = int((img1.size[1] * 0.4 + img2.size[1] * 0.25 + img3.size[1] * 0.25) * 1.3) + yticks_signal = ax.get_yticks()[1:-1] + max_chr_yax = max(len(str(max(yticks_signal))), len(str(min(yticks_signal)))) + signal_left = {3 : 45, 4 : 30, 5 : 20, 6 : 9} + + if max_chr_yax not in signal_left.keys(): + + signal_left[max_chr_yax] = 0 + composite_image = Image.new(mode="RGBA", size=(maxx, 1550)) - composite_image = plot.place_composite(composite_image, f"{plot_filename}_hic.png", 0.5, 100, 50) # HiC image - composite_image = plot.place_composite(composite_image, f"{plot_filename}_signal.png", 0.4, 42, 660) # Signal image + composite_image = plot.place_composite(composite_image, f"{plot_filename}_hic.png", 0.5, 100, 50) # HiC image + composite_image = plot.place_composite(composite_image, f"{plot_filename}_signal.png", 0.4, signal_left[max_chr_yax], 660) # Signal image composite_image = plot.place_composite(composite_image, f"{plot_filename}_kk.png", 0.3, 1300, 50) # KK image composite_image = plot.place_composite(composite_image, f"{plot_filename}_lmi.png", 0.4, 75, 900) # LMI scatter image composite_image = plot.place_composite(composite_image, f"{plot_filename}_gsp.png", 0.25, 900, 900) # Gaudi signal image