stream2.tl.seed_graph

stream2.tl.seed_graph(adata, obsm='X_dr', layer=None, clustering='kmeans', damping=0.75, pref_perc=50, n_clusters=10, max_n_clusters=200, n_neighbors=50, nb_pct=None, paths_favored=[], paths_disfavored=[], label=None, label_strength=2, force=False, use_weights=False, use_partition=False)[source]

Seeding the initial elastic principal graph.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • 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

  • init_nodes_pos (array, shape = [n_nodes,n_dimension],) – optional (default: None) initial node positions

  • init_edges (array, shape = [n_edges,2], optional (default: None)) – initial edges, all the initial nodes should be included in the tree structure

  • clustering (str, optional (default: ‘kmeans’)) – Choose from {{‘ap’,’kmeans’,’sc’}} clustering method used to infer the initial nodes. ‘ap’ affinity propagation ‘kmeans’ K-Means clustering ‘sc’ spectral clustering

  • damping (float, optional (default: 0.75)) – Damping factor (between 0.5 and 1) for affinity propagation.

  • pref_perc (int, optional (default: 50)) – Preference percentile (between 0 and 100). The percentile of the input similarities for affinity propagation.

  • n_clusters (int, optional (default: 10)) – Number of clusters (only valid once ‘clustering’ is specified as ‘sc’ or ‘kmeans’).

  • max_n_clusters (int, optional (default: 200)) – The allowed maximum number of clusters for ‘ap’.

  • n_neighbors (int, optional (default: 50)) – The number of neighbor cells used for spectral clustering.

  • nb_pct (float, optional (default: None)) – The percentage of neighbor cells (when specified, it will overwrite n_neighbors).

  • paths_favored (list of lists, optional (default: [])) – Favored paths between categorical labels used for supervised MST initialization

  • paths_disfavored (list of lists, optional (default: [])) – Disfavored paths between categorical labels used for supervised MST initialization

  • label (str, optional (default: None)) – Categorical labels for supervised MST initialization

  • label_strength (float in [1,oo)) – Strength of supervised MST initialization

  • force (bool) – (experimental feature) Force supervised MST initialization to follow specified paths rather than using soft constraint

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

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

Returns:

  • adata.obs[‘clustering’] (pandas.core.series.Series) – (adata.obs[‘clustering’],dtype str) Array of dim (number of samples) that stores the clustering labels (‘0’, ‘1’, …) for each cell.

  • adata.uns[‘seed_epg’] (dict) – Elastic principal graph structure.