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, neighbors_key=None, obsp=None, copy=False, **kwds)[source]#
- Force-directed graph drawing [Chippada, 2018, Islam et al., 2011, Jacomy et al., 2014]. - An alternative to tSNE that often preserves the topology of the data better. This requires running - neighbors(), first.- The default layout (‘fa’, - ForceAtlas2, Jacomy et al. [2014]) uses the package- fa2-modified[Chippada, 2018], which can be installed via- pip install fa2-modified.- Force-directed graph drawing describes a class of long-established algorithms for visualizing graphs. It was suggested for visualizing single-cell data by Islam et al. [2011]. Many other layouts as implemented in igraph [Csárdi and Nepusz, 2006] are available. Similar approaches have been used by Zunder et al. [2015] or Weinreb et al. [2017]. - Parameters:
- adata AnnData
- Annotated data matrix. 
- layout Literal['fr','drl','kk','grid_fr','lgl','rt','rt_circular','fa'] (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|None(default:None)
- Root for tree layouts. 
- random_state int|RandomState|None(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 spmatrix|None(default:None)
- Sparse adjacency matrix of the graph, defaults to neighbors connectivities. 
- key_added_ext str|None(default:None)
- By default, append - layout.
- proceed
- Continue computation, starting off with ‘X_draw_graph_`layout`’. 
- init_pos str|bool|None(default:None)
- 'paga'/- True,- None/- False, or any valid 2d-- .obsmkey. Use precomputed coordinates for initialization. If- False/- None(the default), initialize randomly.
- neighbors_key str|None(default:None)
- If not specified, draw_graph looks at .obsp[‘connectivities’] for connectivities (default storage place for pp.neighbors). If specified, draw_graph looks at .obsp[.uns[neighbors_key][‘connectivities_key’]] for connectivities. 
- obsp str|None(default:None)
- Use .obsp[obsp] as adjacency. You can’t specify both - obspand- neighbors_keyat the same time.
- copy bool(default:False)
- Return a copy instead of writing to adata. 
- **kwds
- Parameters of chosen igraph layout. See e.g. - layout_fruchterman_reingold()[Fruchterman and Reingold, 1991]. One of the most important ones is- maxiter.
 
- adata 
- Return type:
- Returns:
- Returns - Noneif- copy=False, else returns an- AnnDataobject. Sets the following fields:- adata.obsm['X_draw_graph_[layout | key_added_ext]']- numpy.ndarray(dtype- float)
- Coordinates of graph layout. E.g. for - layout='fa'(the default), the field is called- 'X_draw_graph_fa'.- key_added_extoverwrites- layout.
- adata.uns['draw_graph']:- dict
- draw_graphparameters.