class dmslogo.logo.Memoize(f)[source]

Bases: object

Memoize function from https://stackoverflow.com/a/1988826

class dmslogo.logo.Scale(sx, sy=None)[source]

Bases: RendererBase

Scale letters using affine transformation.

From here: https://www.python-forum.de/viewtopic.php?t=30856

draw_path(renderer, gc, tpath, affine, rgbFace)[source]

Draw the letters.

Draw sequence logo from specified letter heights.

Args:
data (pandas DataFrame)

Holds data to plot.

letter_height_col (str)

Column in data with letter heights.

letter_col (str)

Column in data with letter identities.

x_col (str)

Column in data with integer site numbers.

xtick_col (None or str)

Column in data used to label sites if not using x_col.

color_col (None or str)

Column in data with colors for each letter; set to None to define colors via colorscheme and missing_color.

shade_color_col (None or str)

Column in data indicating color to shade each site. Must be same color for all letters at site. If a site should not be shaded, set to something that evaluates to False or NaN.

shade_alpha_col (None or str)

Column in data giving transparency of shading at each site.

heatmap_overlays (None or list)

List of columns in data giving colors for each overlay.

xlabel (None or str)

Label for x-axis if not using xtick_col or x_col.

ylabel (None or str)

Label for y-axis if not using letter_height_col.

title (None or str)

Title to place above plot.

colorscheme (dict)

Color for each letter. Ignored if color_col is not None. See dmslogo.colorschemes for some color schemes.

missing_color (None or str)

Color for letters not assigned in colorscheme, or None to raise an error for unassigned letters.

addbreaks (bool)

Anywhere there is a gap in sequential numbering of x_col, add break consisting of space and dashed line.

widthscale (float)

Scale width by this much.

heightscale (float)

Scale height by this much.

heatmap_overlay_height (float)

Height of heatmap overlays relative to logo.

axisfontscale (float)

Scale size of font for axis ticks and labels by this much.

hide_axis (bool)

Do we hide the axis and tick labels?

fontfamily (str)

Font to use (for logo letters).

fontaspect (float)

Aspect ratio of logo letter font (height to width). If letters are too crowded, increase this.

letterpad (float)

Add this much fixed vertical padding between letters as fraction of total stack height.

letterheightscale (float)

Scale height of all letters by this much.

ax (None or matplotlib axes.Axes object or list of Axes)

Use to plot on an existing axis. If using heatmap_overlays then must be list of axes of correct length.

ylim_setter (None or dmslogo.utils.AxLimSetter)

Object used to set y-limits. If None, a dmslogo.utils.AxLimSetter is created using default parameters). If fixed_ymin and/or fixed_ymax are set, they override the limits from this setter.

fixed_ymin (None or float)

If not None, then fixed y-axis minimum.

fixed_ymax (None or float)

If not None, then fixed y-axis maximum.

clip_negative_heights (bool)

Set to 0 any value in letter_height_col that is < 0.

drop_na_letter_heights (bool)

Drop any rows in data where letter_height_col is NaN.

draw_line_at_zero (str)

Draw a horizontal line at the value of zero? Can have following values: ‘if_negative’ to only draw line if there are negative letter heights, ‘always’ to always draw line, and ‘never’ to never draw line.

Returns:

The 2-tuple (fig, ax) giving the figure and axis with the logo plots. If using heatmap_overlays, then ax will be an array of all axes (overlays and logo axes).