Skip to content

Commit

Permalink
Merge pull request #31 from microbial-pangenomes-lab/plots_directory
Browse files Browse the repository at this point in the history
New argument for panfeed-plots to allow users to generate plots within a specified directory
  • Loading branch information
haneubau authored Jun 3, 2024
2 parents e504cee + 7a07cde commit 3a91350
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion panfeed/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.0'
__version__ = '1.6.1'
12 changes: 8 additions & 4 deletions panfeed/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def get_options():
default='png',
help='Output format for plots (default %(default)s)')

parser.add_argument('--output-directory',
default='.',
help='Output directory for the plots (default %(default)s)')

parser.add_argument('--dpi',
type=int,
default=300,
Expand Down Expand Up @@ -337,7 +341,7 @@ def handle_paralogs_text(x):
cax = divider.append_axes("right", size="2.5%", pad=0.05)
coba = plt.colorbar(im, cax=cax)
coba.set_label("-log10 p-value")
plt.savefig(f'significance_{gene}.{args.format}', dpi=args.dpi, bbox_inches="tight")
plt.savefig(f'{args.output_directory}/significance_{gene}.{args.format}', dpi=args.dpi, bbox_inches="tight")
logger.info(f'saved plot significance_{gene}.{args.format}')
plt.close()

Expand All @@ -360,7 +364,7 @@ def handle_paralogs_text(x):
ax.set_title(f"nucleotide sequence {gene}")
ax.set_xlabel("position relative to gene start")
ax.set_ylabel(f"{g.shape[0]} samples")
plt.savefig(f'sequence_{gene}.{args.format}', dpi=args.dpi, bbox_inches="tight")
plt.savefig(f'{args.output_directory}/sequence_{gene}.{args.format}', dpi=args.dpi, bbox_inches="tight")
logger.info(f'saved plot sequence_{gene}.{args.format}')
plt.close()

Expand Down Expand Up @@ -389,7 +393,7 @@ def handle_paralogs_text(x):
ax.set_title(f"significant k-mers {gene}")
ax.set_xlabel("position relative to gene start")
ax.set_ylabel(f"{g.shape[0]} samples")
plt.savefig(f'hybrid_{gene}.{args.format}', dpi=args.dpi, bbox_inches="tight")
plt.savefig(f'{args.output_directory}/hybrid_{gene}.{args.format}', dpi=args.dpi, bbox_inches="tight")
logger.info(f'saved plot hybrid_{gene}.{args.format}')
plt.close()

Expand All @@ -406,7 +410,7 @@ def handle_paralogs_text(x):
xticklabels=False,
square=True)

plt.savefig(f'sequence_legend.{args.format}', dpi=args.dpi, bbox_inches="tight")
plt.savefig(f'{args.output_directory}/sequence_legend.{args.format}', dpi=args.dpi, bbox_inches="tight")
logger.info(f"Saved nucleotide color key at sequence_legend.{args.format}")
plt.close()

Expand Down

0 comments on commit 3a91350

Please sign in to comment.