stream2.tl.learn_graph

stream2.tl.learn_graph(adata, method='principal_tree', obsm='X_dr', layer=None, n_nodes=50, epg_lambda=0.01, epg_mu=0.1, epg_alpha=0.02, epg_trimming_radius=inf, use_seed=True, use_partition=False, use_weights=False, ordinal_label=None, ordinal_supervision_strength=1, ordinal_root_point=None, n_jobs=None, GPU=False, max_candidates={'AddNode2Node': 20, 'BisectEdge': 20, 'ShrinkEdge': 50}, store_evolution=False, **kwargs)[source]

Learn principal graph.

Parameters:
  • adata (AnnData) – Anndata object.

  • method (str, (default: ‘principal_curve’);) – Method used to calculate the graph.

  • obsm (str, optional (default: ‘X_dr’)) – The multi-dimensional annotation of observations used to learn the graph

  • layer (str, optional (default: None)) – The layer used to learn the graph

  • use_seed (bool) – Whether to use the seed graph in adata.uns[‘seed_epg’] generated by st.seed_graph. If True, ignores obsm and layer parameters

  • use_partition (bool) – Whether to learn a disconnected graph for each category in adata.uns[‘partition’]

  • use_weights (bool) – Whether to weight points with adata.obs[‘pointweights’]

  • GPU – Whether to perform computations using GPU (requires cupy library)

  • max_candidates – Max number of candidates to generate with each graph grammar when exploring graph topology at each iteration. Setting numbers lower can increase speed, especially for higher number of nodes.

  • store_evolution – Store the evolution of the graph for each number of nodes

  • **kwargs – Additional arguments to each method

Returns:

  • updates adata.uns[‘epg’] with the following fields.

  • conn (sparse matrix (.uns[‘epg’][‘conn’])) – A connectivity sparse matrix.

  • node_pos (array (.uns[‘epg’][‘node_pos’])) – Node positions.

  • edge (array (.uns[‘epg’][‘edge’])) – Node edges.