Heatmap#

missionbio.mosaic.plots.heatmap.Heatmap

class Heatmap(data: DataFrame, y_groups: Sequence, x_groups: Optional[Sequence] = None, palette: Optional[Dict] = None, ytick_proportions: bool = False, title: str = '')#

Heatmap with options for grouping rows/cols.

The xaxis groups (x_groups) or the grouping of columns is represented by appropriate tickvalues on the xaxis. The yaxis groups (y_groups) or the grouping of rows is represented by an extra column showing the color for each group category.

Snippets#

>>> from missionbio.mosaic.plots.heatmap import Heatmap
>>> import numpy as np
>>> import pandas as pd
>>> data = pd.DataFrame(np.arange(10).reshape(5, 2))
>>> hm = Heatmap(data, y_groups=["a", "a", "a", "b", "b"])
>>> hm.draw()

Functions#

Usually, only the draw() method is needed. The other methods are used internally by draw(). They can also be used to create complex custom plots as done in MultiHeatmap.

draw()

Returns:

label_trace([name])

Parameters:

data_trace([name])

Parameters:

label_lines_trace([name])

Parameters:

data_lines_trace(vertical[, name])

Parameters:

set_yticks(fig)

Set the yaxis tickvalues

set_xticks(fig[, tick_axis, overlay_axis])

Set the xaxis tickvalues

coloraxis([colorscale])

Generate the coloraxis for the plot

set_ticks(axis, groups[, proportions])

Set the tickvalues as the unique values in groups

annotation(text[, xref, yref])

Helper function to add an annotation on top of the heatmap

is_contiguous(labels)

Parameters:

Parameters:
datapd.DataFrame

The dataframe whose values are to be plotted. The index name is used for the title of the colorbar, the column names are shown on hovering over the heatmap.

y_groupsnp.ndarray

The labels for each row.

x_groupsnp.ndarray

The label for each column. These must be contiguous. For example, [“1”, “2”, “2”] is permitted, but [“1”, “2”, “1”] is not.

paletteOptional[Dict]

The dictionary with the color for each unique value in y_groups.

ytick_proportionsbool

Whether to show the fraction of rows of each y_group on the y-axis ticks.

titlestr

The title of the plot