rapids_singlecell.tl.draw_graph#

rapids_singlecell.tl.draw_graph(adata, *, init_pos=None, max_iter=500, rng=None, use=None, out=False, key_added=None)[source]#

Force-directed graph drawing [FR91, JVHB14].

Uses cugraph’s implementation of Force Atlas 2. This is a reimplementation of scanpys function for GPU compute.

Parameters:
adata AnnData

annData object with ‘neighbors’ field.

init_pos str | bool | None (default: None)

'paga'/True, None/False, or any valid 2d-.obsm key. Use precomputed coordinates for initialization. If False/None (the default), initialize randomly.

max_iter int (default: 500)

This controls the maximum number of levels/iterations of the Force Atlas algorithm. When specified the algorithm will terminate after no more than the specified number of iterations. No error occurs when the algorithm terminates in this manner. Good short-term quality can be achieved with 50-100 iterations. Above 1000 iterations is discouraged.

rng int | integer | Sequence[int] | SeedSequence | Generator | BitGenerator | None (default: None)

Random seed or Generator used when initializing layout and generating samples. Defaults to 0. If None is passed, a hash of process id, time, and hostname is used by cugraph. The superseded random_state argument is still accepted.

use GraphAcc | str | None (default: None)

The neighborhood graph (connectivities) to lay out, e.g. A.obsp['k']. Strings are resolved by anndata.acc.AdAcc.resolve(), e.g. 'obsp.k'. If None, the one neighbors() wrote by default.

out MultiAcc | str | bool (default: False)

Where to write the coordinates, e.g. A.obsm['fa']; the parameters go to .uns under the same key. If True, the coordinates are returned instead. If False, they are written to .obsm['X_draw_graph_fa'] and .uns['draw_graph'].

Return type:

ndarray | None

Returns:

The coordinates if out=True, else updates adata with the following fields (see out for other keys).

X_draw_graph_layout_faadata.obsm

Coordinates of graph layout.