scanpy.tl.draw_graph¶
-
scanpy.tl.
draw_graph
(adata, layout='fa', init_pos=None, root=None, random_state=0, n_jobs=None, adjacency=None, key_added_ext=None, copy=False, **kwds)¶ Force-directed graph drawing [Islam11] [Jacomy14] [Chippada18].
An alternative to tSNE that often preserves the topology of the data better. This requires to run
neighbors()
, first.The default layout (‘fa’,
ForceAtlas2
) [Jacomy14] uses the package fa2 [Chippada18], which can be installed viapip install fa2
.Force-directed graph drawing describes a class of long-established algorithms for visualizing graphs. It has been suggested for visualizing single-cell data by [Islam11]. Many other layouts as implemented in igraph [Csardi06] are available. Similar approaches have been used by [Zunder15] or [Weinreb17].
Parameters: - adata :
AnnData
Annotated data matrix.
- layout :
str
, optional (default: ‘fa’) ‘fa’ (
ForceAtlas2
) or any valid igraph layout. Of particular interest are ‘fr’ (Fruchterman Reingold), ‘grid_fr’ (Grid Fruchterman Reingold, faster than ‘fr’), ‘kk’ (Kamadi Kawai’, slower than ‘fr’), ‘lgl’ (Large Graph, very fast), ‘drl’ (Distributed Recursive Layout, pretty fast) and ‘rt’ (Reingold Tilford tree layout).- root :
int
orNone
, optional (default:None
) Root for tree layouts.
- random_state :
int
orNone
, optional (default: 0) For layouts with random initialization like ‘fr’, change this to use different intial states for the optimization. If
None
, no seed is set.- adjacency : sparse matrix or
None
, optional (default:None
) Sparse adjacency matrix of the graph, defaults to
adata.uns['neighbors']['connectivities']
.- key_ext :
str
, optional (default:None
) By default, append
layout
.- proceed :
bool
, optional (default:None
) Continue computation, starting off with ‘X_draw_graph_`layout`’.
- init_pos : {‘paga’, any valid 2d-
.obsm
key,False
}, optional (default:False
) Use precomputed coordinates for initialization.
- copy :
bool
(default:False
) Return a copy instead of writing to adata.
- **kwds : further parameters
Parameters of chosen igraph layout. See, e.g., fruchterman_reingold. One of the most important ones is
maxiter
.
Returns: - Depending on
copy
, returns or updatesadata
with the following field. - X_draw_graph_`layout` (
adata.obsm
) – Coordinates of graph layout. E.g. for layout=’fa’ (the default), the field is called ‘X_draw_graph_fa’
- adata :