anndict.plot.plot_sankey#
- anndict.plot.plot_sankey(adata, cols, params=None)[source]#
Generate a Sankey diagram from the specified columns in
adata.obs.- Parameters:
- adata
AnnData An
AnnDataobject.- cols
list[str] The list of column names in
adata.obsfrom which to construct the Sankey diagram.- params
dict[str,str|int|float|bool] |None(default:None) A
dictof 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').
- adata
- 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')