mcbrowse.figures.interface

The common interface implemented by all figures.

In general, each figure defines the following:

  • A FigureFilter object that describes how to collect the data.

  • A FigureData object that contains the collected data.

  • A FigureVeneer object that defines how to format the figure.

class mcbrowse.figures.interface.FigureFilter(*args, **kwds)[source]

Bases: ABC, Generic[AnyDataT]

Control how to extract the figure data from the daf repository.

Todo

Have each FigureFilter expose a plotly widget that configures it.

abstract collect(data: DafReader) AnyDataT[source]

Collect the matching FigureData out of the data.

class mcbrowse.figures.interface.FigureData[source]

Bases: ABC

Contain the data to be included in the figure.

Note

This applies to most figures, but not to heatmaps.

abstract filter(filter: Union[Dict[str, Union[Callable[[Vector], bool], Collection[Any]]], Callable[[Series], bool]]) None[source]

Filter the contained data using tidy_filter_data.

Note

To filter the rows or columns of a heatmap, specify a TidyFilter that filters the rows or columns axis used by the figure.

abstract highlight(filter: Union[Dict[str, Union[Callable[[Vector], bool], Collection[Any]]], Callable[[Series], bool]]) None[source]

Mark everything matching the filter as “highlighted” using tidy_filter_mask. This will trigger using a different veneer for the highlighted data (the details will depend on the specific figure).

Figures are expected to plot the normal data first and the highlighted data later (“on top” of the normal data).

Note

This can only be called once.

abstract sort(order: Union[Callable[[Series], Any], Sequence[str]]) None[source]

Sort the contained data using tidy_sort_by.

Figures are expected to plot the normal data first and the highlighted data later (“on top” of the normal data), but will use the sort order within each category.

abstract randomize(random_seed: Optional[int]) None[source]

Randomize the contained data using tidy_randomize.

Figures are expected to plot the normal data first and the highlighted data later (“on top” of the normal data), but will randomize the order within each group.

class mcbrowse.figures.interface.TidyFigureData(tidy: Union[FrameInRows, FrameInColumns])[source]

Bases: FigureData

Implement FigureData for the very common case of a tidy pandas.DataFrame.

tidy: Optional[Union[FrameInRows, FrameInColumns]]

The tidy data frame containing the figures data.

If we are highlighting, this will only contain the “normal” (non-highlighted) data.

If all the data is highlighted, this will be None.

highlighted: Optional[Union[FrameInRows, FrameInColumns]]

If we are highlighting, this will only contain the highlighted data.

filter(filter: Union[Dict[str, Union[Callable[[Vector], bool], Collection[Any]]], Callable[[Series], bool]]) None[source]

Filter the contained data using tidy_filter_data.

Note

To filter the rows or columns of a heatmap, specify a TidyFilter that filters the rows or columns axis used by the figure.

highlight(filter: Union[Dict[str, Union[Callable[[Vector], bool], Collection[Any]]], Callable[[Series], bool]]) None[source]

Mark everything matching the filter as “highlighted” using tidy_filter_mask. This will trigger using a different veneer for the highlighted data (the details will depend on the specific figure).

Figures are expected to plot the normal data first and the highlighted data later (“on top” of the normal data).

Note

This can only be called once.

sort(order: Union[Callable[[Series], Any], Sequence[str]]) None[source]

Sort the contained data using tidy_sort_by.

Figures are expected to plot the normal data first and the highlighted data later (“on top” of the normal data), but will use the sort order within each category.

randomize(random_seed: Optional[int] = None) None[source]

Randomize the contained data using tidy_randomize.

Figures are expected to plot the normal data first and the highlighted data later (“on top” of the normal data), but will randomize the order within each group.

class mcbrowse.figures.interface.HeatmapData[source]

Bases: ABC

Contain the heatmap data to be included in the figure.

Todo

Add clustering control and clustering-preserving sorting to HeatmapData.

Todo

Create a SimpleHeatmapData implementation that keeps both a 2D matrix and a frame of annotations for the rows and the columns.

abstract filter(*, rows_filter: Optional[Union[Callable[[Vector], bool], Collection[Any]]] = None, columns_filter: Optional[Union[Callable[[Vector], bool], Collection[Any]]] = None) None[source]

Filter the contained data using matrix_filter_data.

class mcbrowse.figures.interface.FigureVeneer(*args, **kwds)[source]

Bases: ABC, Generic[AnyDataT]

Contain the parameters controlling the figure’s appearance.

Todo

Have each FigureVeneer expose a plotly widget that configures it.

abstract plot(data: AnyDataT) BaseFigure[source]

Generate the plotly figure using the specified data.