Welcome to render-psam’s documentation!

render-psam is a Python package that wraps logomaker to render Position Specific Affinity Matrices (PSAMs) in a more user-friendly way.

render_psam.render_psam(psam, psam_mode='normalized', ax=None, **kwargs)

Render a PSAM as a LogoMaker logo. Any NaNs in the PSAM will be replaced with near-0 values so that they don’t cause the LogoMaker to crash. This means that if you provide an all-NaN PSAM, you’ll get a uniform logo

Parameters:
  • psam – The PSAM to render. Shape (L, 4).

  • psam_mode – One of “raw”, “normalized”, or “info”. * “raw” means to plot the raw PSAM * “normalized” means to first ensure that the PSAM sums to 1 at each position, and then plot the result. * “info” means to treat the PSAM as a probability distribution over nucleotides at each position, and then plot the sequence logo by plotting a PSAM that sums to 2 - H(p) at each position.

  • ax – The axis to plot on. If None, use the current axis.

  • kwargs – Additional keyword arguments to pass to logomaker.Logo

render_psam.render_psams(psams, *, names, ncols=1, width=5, figure_kwargs=None, axes_mode='completely_blank', same_ylim=False, **kwargs)

Render several PSAMs in a grid. The grid will have ncols columns, and as many rows as necessary to fit all the PSAMs.

Each PSAM will be rendered using render_psam, and the kwargs will be passed to it. The canvas for each PSAM will be a width-inch wide by 1.6-inch tall figure.

Parameters:
  • psams – The PSAMs to render. Each PSAM should be a 2D array of shape (L, 4).

  • names – The names of the PSAMs. These will be used as the titles of the subplots.

  • ncols – The number of columns in the grid.

  • width – The width of each subplot, in inches.

  • figure_kwargs – The keyword arguments to pass to plt.figure.

  • axes_mode – One of “completely_blank” or “just_y”. If “completely_blank”, then the axis will be completely blank, with no ticks or labels. If “just_y”, then the axis will be blank except for the y-axis.

  • same_ylim – If True, then all the subplots will have the same y-axis limits.

  • kwargs – The keyword arguments to pass to render_psam.

render_psam.clean(ax, *, simplified=False)

Clean up an axis by removing the top and right spines, and optionally the left and bottom spines.

Parameters:
  • ax – The axis to clean.

  • simplified – If True, then also remove the left and bottom spines.