class MultiHeatmap(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_columns: int = 0, extra_column_titles: Sequence[str] = ())#

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.


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

>>> from missionbio.mosaic.plots.multi_heatmap import MultiHeatmap
>>> 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 = MultiHeatmap(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.mosaic.plots.multi_heatmap import MultiHeatmap >>> from missionbio.mosaic.plots.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] >>> fig = MultiHeatmap(datas, y_groups=[“a”, “b”], extra_columns=1, extra_column_titles=[“Bar”]).draw() >>> fig.add_trace(bar.trace(), row=1, col=2) # Add the bar graph to the empty second column



Draw the plot


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.


The labels for each row.


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


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


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.


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


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


The title of the plot


The number of extra columns to be added to the left of the heatmaps. 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.multi_heatmap.MultiHeatmap.draw().


The titles for the extra columns. It should have the same length as extra_columns.