Heatmap¶
Widgets¶
Higher level widgets that are directly used by the end-user. Both Heatmap widgets use the same plot variant.
HeatmapSplitterWidget¶
Heatmap with a vertical splitter that can be used to house another widget. The plot is compatible with both ‘row’ and ‘item’ selection modes.
-
class
mesmerize.plotting.
HeatmapSplitterWidget
(highlight_mode='row')[source]¶ Widget for interactive heatmaps
-
__init__
(highlight_mode='row')[source]¶ - Parameters
highlight_mode – Interactive mode, one of ‘row’ or ‘item’
-
set_data
(dataframes: Union[pandas.core.frame.DataFrame, list], data_column: str, labels_column: str, cmap: str = 'jet', transmission: Optional[mesmerize.analysis.data_types.Transmission] = None, sort: bool = True, reset_sorting: bool = True, **kwargs)[source]¶ Set the data and then set the plot
- Parameters
dataframes – list of dataframes or a single DataFrame
data_column – data column of the dataframe that is plotted in the heatmap
labels_column – dataframe column (usually categorical labels) used to generate the y-labels and legend.
cmap – colormap choice
transmission – transmission object that dataframe originates, used to calculate data units if passed
sort – if False, the sort comboBox is ignored
reset_sorting – reset the order of the rows in the heatmap
kwargs – Passed to Heatmap.set
-
_set_sort_order
(column: str)[source]¶ Set the sort order of the heatmap rows according to a dataframe column. The column must contain categorical values. The rows are grouped together according to the categorical values.
- Parameters
column – DataFrame column containing categorical values used for sorting the heatmap rows
-
HeatmapTracerWidget¶
Heatmap with an embedded Datapoint Tracer that can be saved and restored.
-
class
mesmerize.plotting.
HeatmapTracerWidget
[source]¶ Bases:
mesmerize.plotting.widgets.base.BasePlotWidget
,mesmerize.plotting.widgets.heatmap.widget.HeatmapSplitterWidget
Heatmap with an embedded datapoint tracer
-
drop_opts
= ['dataframes', 'transmission']¶ keys of the plot_opts dict that are not JSON compatible and not required for restoring this plot
-
live_datapoint_tracer
¶ The embedded Datapoint Tracer <API_DatapointTracer>
-
set_current_datapoint
(ix: tuple)[source]¶ Set the currently selected datapoint in the Datapoint Tracer.
- Parameters
ix – index, (x, y). x is always 0 for this widget since it only uses ‘row’ selection mode and not ‘item’
-
get_plot_opts
(drop: bool = False) → dict[source]¶ Get the plot options
- Parameters
drop – Drop the non-json compatible objects that are not necessary to restore this plot
-
set_data
(*args, datapoint_tracer_curve_column: str = None, **kwargs)[source]¶ Set the plot data, parameters and draw the plot. If the input Transmission comes directly from the FCluster it will pass a dict from get_cluster_kwargs() to the cluster_kwargs argument. Else it will pass None to cluster_kwargs.
- Parameters
args – arguments to pass to superclass set_data() method
datapoint_tracer_curve_column – Data column containing curves to use in the datapoint tracer
kwargs – keyword arguments, passed to superclass set_data() method
-
property
transmission
¶ The input transmission
- Return type
-
save_plot_dialog
(path, *args)¶ Plot save dialog
-
save_plot
(path)¶ Save the plot as a Transmission in an HDF5 file. Plot parameters are stored as a JSON string within the HDF5 file. See Transmission.to_hdf5
- Parameters
path – Path to save the file to. For easy identification use “.ptrn” extension.
-
open_plot_dialog
(filepath, dirpath, *args, **kwargs)¶ Open plot dialog
-
Variant¶
Lower level widget that handles the actual plotting and user interaction
-
class
mesmerize.plotting.variants.
Heatmap
(highlight_mode='row')[source]¶ Bases:
mesmerize.pyqtgraphCore.widgets.MatplotlibWidget.MatplotlibWidget
Heatmap plot variant
-
sig_selection_changed
¶ Emits indices of data coordinates (x, y) from mouse-click events on the heatmap
-
__init__
(highlight_mode='row')[source]¶ - Parameters
highlight_mode – The selection mode for the heatmap. One of either ‘row’ or ‘item’
-
data
¶ 2D numpy array of the heatmap data
-
selector
¶ Selection instance that organizes mouse click events on the heatmap
-
plot
¶ ClusterGrid object instance containing the plot Axes
-
set
(data: numpy.ndarray, *args, ylabels: Optional[Union[pandas.core.series.Series, numpy.ndarray, list]] = None, ylabels_cmap: str = 'tab20', cluster_kwargs: Optional[dict] = None, **kwargs)[source]¶ - Parameters
data – 2D numpy array
args – Additional args that are passed to sns.heatmap()
ylabels – Labels used to create the ylabels bar
ylabels_cmap – colormap for the ylabels bar
cluster_kwargs – keywoard arguments for visualizing hierarchical clustering
kwargs – Additional kwargs that are passed to sns.heatmap()
-