Skip to content

Plotting

mina.pl.plot_view_samples(anndata_dict, min_samples, table=False, figsize=(5, 5), dpi=100, ax=None, return_fig=False, **kwargs)

Quality control plot to assess the quality of the obtained pseudobulk samples.

Parameters:

Name Type Description Default
anndata_dict dict[str, AnnData]

Dictionary mapping view names to AnnData objects.

required
min_samples int

Minimum number of samples required for a view to be included.

required
table bool

Whether to return the underlying summary table instead of plotting. Default is False.

False
figsize tuple[int, int]

Size of the figure in inches. Default is (5, 5).

(5, 5)
dpi int

Resolution of the figure in dots per inch. Default is 100.

100
ax Axes or None

Matplotlib Axes object to plot on. If None, a new figure and axes are created.

None
return_fig bool

Whether to return the Figure object. Default is False.

False
**kwargs dict

Additional keyword arguments passed to seaborn.scatterplot.

{}

Returns:

Name Type Description
fig Figure or None

The created Figure object if return_fig is True, otherwise None.

mina.pl.plot_view_genes(anndata_dict, min_genes, table=False, figsize=(5, 5), dpi=100, ax=None, return_fig=False, **kwargs)

Quality control plot to assess the quality of the obtained pseudobulk samples.

Parameters:

Name Type Description Default
anndata_dict dict[str, AnnData]

Dictionary mapping view names to AnnData objects.

required
min_genes int

Minimum number of genes required for a view to be included.

required
table bool

Whether to return the underlying summary table instead of plotting. Default is False.

False
figsize tuple[int, int]

Size of the figure in inches. Default is (5, 5).

(5, 5)
dpi int

Resolution of the figure in dots per inch. Default is 100.

100
ax Axes or None

Matplotlib Axes object to plot on. If None, a new figure and axes are created.

None
return_fig bool

Whether to return the Figure object. Default is False.

False
**kwargs dict

Additional keyword arguments passed to seaborn.scatterplot.

{}

Returns:

Name Type Description
fig Figure or None

The created Figure object if return_fig is True, otherwise None.

mina.pl.plot_sample_coverage(anndata_dict, threshold, proportion, table=False, figsize=(5, 5), dpi=100, return_fig=False, **kwargs)

Visualize sample coverage for each AnnData view.

Samples below the requested proportion threshold are highlighted. One figure is produced per dictionary key.

Parameters:

Name Type Description Default
anndata_dict dict[str, AnnData]

Dictionary mapping view names to AnnData objects.

required
threshold float or dict[str, float]

Gene expression threshold. If a dict, must contain all keys of anndata_dict.

required
proportion float or dict[str, float]

Minimum proportion of genes above threshold. If a dict, must contain all keys.

required
table bool

If True, return summary tables instead of plotting. Default is False.

False
figsize tuple[int, int]

Figure size per subplot. Default is (5, 5).

(5, 5)
dpi int

Figure resolution in dots per inch. Default is 100.

100
return_fig bool

If True, return the generated Figure objects. Default is False.

False
**kwargs dict

Additional keyword arguments passed to matplotlib.axes.Axes.scatter.

{}

Returns:

Type Description
dict[str, DataFrame] or dict[str, Figure] or None

Summary tables if table is True, figures if return_fig is True, otherwise None.

mina.pl.plot_pval_tiles(p_df: pd.DataFrame, star_threshold: float = 0.05, ax=None, title: str | None = None)

Create a tile plot of -log10(p) values.

Parameters:

Name Type Description Default
p_df DataFrame

DataFrame of p-values with rows and columns defining the tile grid.

required
star_threshold float

P-value threshold for star annotation. Default is 0.05.

0.05
ax Axes or None

Axes to draw on. If None, a new figure and axes are created.

None
title str or None

Optional title for the plot.

None

Returns:

Name Type Description
axes Axes or tuple[Figure, Axes]

Existing axes when ax is provided, otherwise the created figure and axes.

mina.pl.plot_mcell_funcomics(result_dict: dict[str, dict[str, pd.DataFrame]], result_key: str = 'pw_acts', pval_key: str = 'pw_padj', p_threshold: float = 0.05, top_n: int = 10, cmap: str = 'coolwarm', figsize: tuple = (14, 5), ytick_rotation: int = 0, use_var: bool = False)

Plot grouped heatmaps per view using a selected result matrix.

Features are filtered by adjusted p-value and ranked either by mean absolute value or variance.

Parameters:

Name Type Description Default
result_dict dict[str, dict[str, DataFrame]]

Output of run_ulm_per_view with one entry per view.

required
result_key str

Key within each view result containing values to plot.

'pw_acts'
pval_key str

Key within each view result containing adjusted p-values.

'pw_padj'
p_threshold float

Adjusted p-value significance threshold.

0.05
top_n int

Number of top significant features per view to display.

10
cmap str

Colormap for the heatmaps.

'coolwarm'
figsize tuple[int, int]

Overall figure size.

(14, 5)
ytick_rotation int

Rotation angle for y-axis tick labels.

0
use_var bool

If True, rank features by variance instead of mean absolute value.

False

Returns:

Type Description
None

The function displays the plot and does not return an object.

mina.pl.plot_mcell_network(df: pd.DataFrame, weight_col: str = 'coef', abs_cutoff: float = 0.0, keep_negative: bool = True, edge_width_range: tuple = (0.8, 6), node_size: int = 1100, arrowsize: int = 18, reciprocal_curvature: float = 0.25, default_curvature: float = 0.04, positive_color: str = 'tab:purple', negative_color: str = 'tab:red', show_edge_labels: bool = False, label_fmt: str = '{:.2f}', title: str | None = None, save_path: str | None = None, edge_margin_factor: float = 0.55, arrows_on_top: bool = True)

Plot an inferred multicellular information network.

The results are shown solely from one subset (positive or negative loadings).

Parameters:

Name Type Description Default
df DataFrame

DataFrame defining directed edges. Must contain at least source, target, and edge weight columns.

required
weight_col str

Column name containing edge weights. Default is "coef".

'coef'
abs_cutoff float

Minimum absolute weight required to keep an edge.

0.0
keep_negative bool

Whether to retain negatively weighted edges.

True
edge_width_range tuple[float, float]

Minimum and maximum edge widths used for scaling.

(0.8, 6)
node_size int

Size of network nodes.

1100
arrowsize int

Size of arrow heads.

18
reciprocal_curvature float

Curvature used for reciprocal edges.

0.25
default_curvature float

Curvature used for non-reciprocal edges.

0.04
positive_color str

Color for positively weighted edges.

'tab:purple'
negative_color str

Color for negatively weighted edges.

'tab:red'
show_edge_labels bool

Whether to display edge weight labels.

False
label_fmt str

Format string used for edge labels.

'{:.2f}'
title str or None

Optional plot title.

None
save_path str or None

If provided, save the figure to this path.

None
edge_margin_factor float

Factor controlling spacing between nodes and edges.

0.55
arrows_on_top bool

Whether arrows are drawn above nodes.

True

Returns:

Name Type Description
graph DiGraph

Directed graph built from the filtered network table.

mina.pl.plot_features_per_view(df_dict: dict[str, pd.DataFrame], features: list[str], cmap: str = 'coolwarm', figsize: tuple[int, int] = (14, 5), ytick_rotation: int = 0, xtick_rotation: int = 90, share_color_scale: bool = True, center: float | None = 0.0)

Plot grouped heatmaps for selected features across multiple views.

Each entry in df_dict is a dataframe for one view, with rows as samples and columns as features. For each view, only the requested features present in the dataframe are plotted.

Parameters:

Name Type Description Default
df_dict dict[str, DataFrame]

Dictionary mapping view names to sample-by-feature matrices.

required
features list[str]

Feature names to plot in each view when present.

required
cmap str

Matplotlib colormap name.

'coolwarm'
figsize tuple[int, int]

Overall figure size.

(14, 5)
ytick_rotation int

Rotation angle for y-axis tick labels.

0
xtick_rotation int

Rotation angle for x-axis tick labels.

90
share_color_scale bool

Whether all heatmaps use a shared color scale.

True
center float or None

Center value for diverging color scaling. If None, no center is used.

0.0

Returns:

Type Description
None

The function displays the plot and does not return an object.

mina.pl.plot_comm_overview(plot_df, tile_width=0.6, tile_height=0.6, text_size=5, figsize=None, source_label='source', target_label='target', ax=None)

Plot ligand-receptor coherent interactions as source/target tiles.

Parameters:

Name Type Description Default
plot_df DataFrame

Output from generate_lr_plot_df.

required
tile_width float

Width of each rectangular tile.

0.6
tile_height float

Height of each rectangular tile.

0.6
text_size float

Font size of + / - labels inside tiles.

5
figsize tuple or None

Matplotlib figure size. If None, size is inferred from data dimensions.

None
source_label str

Label for source side of x-axis.

'source'
target_label str

Label for target side of x-axis.

'target'
ax Axes or None

Existing axis to plot into.

None

Returns:

Name Type Description
fig Figure

Figure containing the communication overview.

ax Axes

Axes containing the communication overview.