MultiMap

Contents

MultiMap#

missionbio.plotting.multimap.MultiMap

class MultiMap(datas: Sequence[DataFrame], y_groups: Sequence, names: Optional[Sequence[str]] = None, widths: Optional[Sequence[float]] = None, x_groups: Optional[Sequence[Optional[ndarray]]] = None, palette: Optional[Dict] = None, ytick_proportions: bool = False, title: str = '', extra_column_titles: Sequence[str] = (), label_drawn: bool = True)#

Multiple heatmaps with a common y-axis.

This uses Heatmap() to plot each heatmap. Each heatmap is plotted in a separate subplot and each of them has their own colorbar.

Snippets#

A multi-heatmap with two heatmaps and a common y-axis:

>>> from missionbio.plotting.multimap import MultiMap
>>> import pandas as pd
>>> import numpy as np
>>>
>>> data1 = pd.DataFrame(np.arange(10).reshape(5, 2))
>>> data2 = pd.DataFrame(np.arange(30, 20, -1).reshape(5, 2))
>>> datas = [data1, data2]
>>> hm = MultiMap(datas, y_groups=["a", "a", "a", "b", "b"])
>>> hm.draw()

A multi-heatmap with two heatmaps and a common y-axis and a bar graph on the left: >>> from missionbio.plotting.multimap import MultiMap >>> from missionbio.plotting.bargraph import BarGraph >>> import pandas as pd >>> import numpy as np >>> >>> data = pd.Series([75, 25], index=[“a”, “b”]) >>> bar = BarGraph(data, text=data.values / 100) >>> >>> data1 = pd.DataFrame(np.arange(10).reshape(2, 5)) >>> data2 = pd.DataFrame(np.arange(30, 20, -1).reshape(2, 5)) >>> datas = [data1, data2] >>> mm = MultiMap(datas, y_groups=[“a”, “b”], extra_column_titles=[“Bar”]) >>> fig = mm.draw() >>> fig.add_trace(bar.trace(), row=1, col=2) # Add the bar graph to the empty second column

Functions#

draw([heatmap_columns])

Draw the plot.

Parameters:
dataspd.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.

namesOptional[Sequence[str]]

The suffix for each heatmap trace’s and the scatter line trace’s name. It should have the same length as datas.

widthsOptional[Sequence[float]]

The proportion of the figure space taken by the corresponding data. It should have the same length as datas + number of extra_columns

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. It should have the same length as datas.

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

extra_column_titlesSequence[str]

The titles for the extra columns. The extra columns will be added to the left of the heatmaps, by default. These columns can be used to plot additional information, such as bar graphs. The position of the extra columns can be modified by passing the heatmap_columns argument to missionbio.mosaic.plots.multimap.MultiMap.draw().

label_drawn: bool

Whether an extra heatmap trace with specific colors for each label should be created

Returns:
figplotly.graph_objects.Figure