anndict.wrappers.plot_sankey_adata_dict

anndict.wrappers.plot_sankey_adata_dict#

anndict.wrappers.plot_sankey_adata_dict(adata, cols, params=None)[source]#

Generate a Sankey diagram from the specified columns in adata.obs.

Parameters:
adata AnnData

An AnnData object.

cols list[str]

The list of column names in adata.obs from which to construct the Sankey diagram.

params dict[str, str | int | float | bool] | None (default: None)

A dict of optional parameters to customize the Sankey diagram appearance. Supported keys include:

  • 'cmap': str, colormap for node colors (default: 'Colorblind').

  • 'label_position': str, position of node labels ('outer' or 'center', default: 'outer').

  • 'edge_line_width': int, width of the edges (default: 0).

  • 'edge_color': str, attribute for edge coloring (default: 'value', or 'grey' for uniform color).

  • 'show_values': bool, whether to display flow values (default: False).

  • 'node_padding': int, padding between nodes (default: 12).

  • 'node_alpha': float, transparency of nodes (default: 1.0).

  • 'node_width': int, width of nodes (default: 30).

  • 'node_sort': bool, whether to sort nodes (default: True).

  • 'frame_height': int, height of the diagram frame (default: 1000).

  • 'frame_width': int, width of the diagram frame (default: 2000).

  • 'bgcolor': str, background color of the diagram (default: 'white').

  • 'apply_ranges': bool, whether to apply range adjustments to the plot (default: True).

  • 'align_thr': float, alignment threshold for colors (default: -0.1).

  • 'label_font_size': str, font size for labels (default: '12pt').

Return type:

Literal['holoviews.Sankey']

Returns:

A Holoviews Sankey diagram object.

Example

sankey = plot_sankey(adata, cols=['cell_sub_type', 'cell_type', 'compartment'], params={'cmap': 'viridis', 'frame_width': 1200})
hv.save(sankey, 'sankey_diagram.html')