metacell.dash package

Submodules

metacell.dash.app module

Make the URL reflect the state of the application.

This is heavily modified from: https://gist.github.com/jtpio/1aeb0d850dcd537a5b244bcf5aeaa75b See: https://github.com/plotly/dash/issues/188 for details

class metacell.dash.app.ComponentData(id: str, properties: List[str], dumper: Optional[Callable], loader: Optional[Callable])

Bases: object

Data remembered per component.

__init__(id: str, properties: List[str], dumper: Optional[Callable], loader: Optional[Callable]) → None

Initialize self. See help(type(self)) for accurate signature.

by_name = None

All the known component’s data.

dumper = None

How to convert property values from storage into Dash.

id = None

The unique identifier of the component.

load(params: Dict[str, Any], kwargs: Dict[str, Any]) → None

Load the data from the stored parameters into the keyword arguments.

loader = None

How to convert property values from Dash in to storage.

properties = None

The list of properties to save for the component.

metacell.dash.app.DEFAULT_MAX_COLUMNS = 200

The default number of columns to display in a metacell.dash.app.ResampledHeatmap.

metacell.dash.app.DEFAULT_MAX_ROWS = 200

The default number of rows to display in a metacell.dash.app.ResampledHeatmap.

class metacell.dash.app.ResampledHeatmap(*, aggregation: str = 'mean', data: Optional[Dict[str, Any]] = None, layout: Optional[Dict[str, Any]] = None, max_rows: int = 200, max_columns: int = 200)

Bases: object

Support displaying a large heatmap.

If the visible data is larger than some threshold, it is aggregated using some function. The aggregated data loses the original labels (as each entry is the aggregation of several labeled entries).

__init__(*, aggregation: str = 'mean', data: Optional[Dict[str, Any]] = None, layout: Optional[Dict[str, Any]] = None, max_rows: int = 200, max_columns: int = 200) → None

Create an empty resampled heatmap state.

aggregation = None

How to aggregate the data.

aggregations = {'max': <function ResampledHeatmap._max>, 'mean': <function ResampledHeatmap._mean>, 'median': <function ResampledHeatmap._median>, 'min': <function ResampledHeatmap._min>, 'std': <function ResampledHeatmap._std>, 'sum': <function ResampledHeatmap._sum>, 'var': <function ResampledHeatmap._var>}

Supported aggregation methods.

column_scale = None

How many original columns are aggregated into each visible column.

data = None

The heatmap configuration data to use.

display_frame(selection: Optional[Dict[str, Any]] = None) → pandas.core.frame.DataFrame

Return the data to display given some user selection.

property frame

The full data frame being displayed.

layout = None

The layout to use.

max_columns = None

The maximal number of columns to display. If more columns are displayed, they will be aggregated.

max_rows = None

The maximal number of rows to display. If more rows are displayed, they will be aggregated.

relayout_figure(selection: Optional[Dict[str, Any]] = None) → Dict[str, Any]

Return the figure to use given a relayoutData event.

TODO: This handles zoom events but struggles with pan events.

row_scale = None

How many original rows are aggregated into each visible row.

start_column = None

The index of the first visible column.

start_row = None

The index of the first visible row.

stop_column = None

The index of the first non-visible column.

stop_row = None

The index of the first non-visible row.

metacell.dash.app.app(content: Callable[Dict[str, str], List[Any]]) → Any

Create a Dash application.

The content function should take a params dictionary and use it to create each component.

metacell.dash.app.apply_filter_action(data: numpy.ndarray, filter_action: Dict[str, Any]) → tgutils.numpy.ArrayBool

Apply a filter to an array of values.

metacell.dash.app.component(params: Dict[str, str], *, properties: List[str] = ['value'], dumper: Optional[Callable] = None, loader: Optional[Callable] = None) → Any

Create a dash component in the HTML content.

Invoke component(params)(dcc.Something)(id='...', ...) instead of dcc.Something(id='...', ...).

Specify properties unless you only need to store the value property.

Specify a dumper and a loader if there is a need to convert between the Dash value(s) and the stored value(s) (e.g., storing identifiers for a component that uses row indices). They are given a dictionary containing the properties and can modify them as needed.

metacell.dash.app.parse_filter_query(filter_query: Optional[str]) → List[Dict[str, Any]]

Parse a Dash filter query into a list of filter actions.

Each action is a dictionary with the column_id, operator, and the value.

metacell.dash.app.reset_stat_button(text: str = 'Reset Stat') → Any

Create a “Reset Stat” button.

Clicking the button clears the Stat cache. This is needed if Stat decided some file(s) do not exist, but they were created later (from outside the application).

metacell.dash.app.save_button(text: str = 'Save') → Any

Create a “Save State” button.

Clicking the button saves the current state of the application in a disk file .dash/UUID and places the UUID in the URL query.

When loading the page, specifying ?uuid=UUID may be used to retrieve the application state from the disk file.

metacell.dash.main module

Main program for Metacell interactive dashboard.

metacell.dash.main.DEFAULT_PAGE_SIZE = 31

The default number of rows in a single table page.

metacell.dash.main.main() → None

Main Dash program.

metacell.dash.plots module

Actually plot the graphs.

Module contents