schist.tools._draw_graph

Module Contents

Functions

draw_graph(adata[, layout, use_tree, random_seed, ...])

Extends scanpy.tools.draw_graph function using some layouts available in

Attributes

_LAYOUTS

_Layout

schist.tools._draw_graph._LAYOUTS = ('fr', 'sfdp', 'arf')
schist.tools._draw_graph._Layout
schist.tools._draw_graph.draw_graph(adata: anndata.AnnData, layout: _Layout = 'sfdp', use_tree: bool = False, random_seed: int | None = None, adjacency: scipy.sparse.spmatrix | None = None, key_added_ext: str | None = None, key: str | None = 'schist', copy: bool = False, **kwds)

Extends scanpy.tools.draw_graph function using some layouts available in graph-tool library. Three layouts are available here:

  • SFDP spring-block layout.

  • ARF spring-block layout.

  • Fruchterman-Reingold spring-block layout.

Fruchterman-Reingold is already available in scanpy, but here can be used to render the nested model tree.

In order to use these plotting function, the NestedBlockState needs to be saved when building the model, so save_state=True needs to be set.

Parameters

adata

Annotated data matrix. A NestedBlockState object needs to be saved

layout

A layout among ‘sfdp’, ‘fr’ or ‘arf’. Other graph-tool layouts haven’t been implemented.

use_tree

When this is set, the tree of the nested model is used to generate layout, otherwise the layout only accounts for the neighborhood graph.

random_seed

Random number to be used as seed for graph-tool

adjacency

Sparse adjacency matrix of the graph, defaults to adata.uns[‘neighbors’][‘connectivities’].

key_added_ext

By default, append layout.

key

The slot in AnnData.uns containing the state. Default is ‘nsbm’

copy

Return a copy instead of writing to adata.

**kwds

Parameters of chosen igraph layout. See e.g. fruchterman-reingold [Fruchterman91]. One of the most important ones is maxiter.

Returns

Depending on copy, returns or updates adata with the following field.

X_draw_graph_layoutadata.obsm

Coordinates of graph layout. E.g. for layout=’fa’ (the default), the field is called ‘X_draw_graph_fa’