dynamo.vf.streamline_clusters

dynamo.vf.streamline_clusters(adata, basis='umap', features=['speed', 'divergence', 'acceleration', 'curvature', 'curl'], method='sparsevfc', xy_grid_nums=[50, 50], density=5, curvature_method=1, feature_bins=10, clustering_method='leiden', assign_fixedpoints=False, reversed_fixedpoints=False, **kwargs)[source]

Cluster 2D streamlines based on vector field features. Initialize a grid over the state space and compute the flow of data through the grid using plt.streamplot with a given density. For each point individual streamline, computes the vector field ‘features’ of interest and stores the data via histograms. Add fixed points and “reversed fixed points” (sources of the streamlines) to the feature data dataframe based on the ‘assigned_fixedpoints’ and ‘reversed_fixedpoints’ args. Finally, then cluster the streamlines based on these features using the given ‘clustering_method’.

Parameters:
  • adata (AnnData) – An AnnData object representing the network to be analyzed.

  • basis (str) – The basis to use for creating the vector field, either “umap” or “tsne”. Defaults to “umap”.

  • features (list) – A list of features to calculate for each point in the vector field. Defaults to [“speed”, “divergence”, “acceleration”, “curvature”, “curl”].

  • method (str) – The method to use for calculating the flow of data through the grid, either “sparsevfc” or “gaussian”. Defaults to “sparsevfc”.

  • xy_grid_nums (list) – The number of points to use in the x and y dimensions of the grid. Defaults to [50, 50].

  • density (float) – The density of the grid. Defaults to 5.

  • curvature_method (int) – The method to use for calculating curvature. Defaults to 1.

  • feature_bins (int) – The number of bins to use for discretizing the data. Defaults to 10.

  • clustering_method (str) – The method to use for clustering the data into modules, either “louvain” or “leiden”. Defaults to “leiden”.

  • assign_fixedpoints (bool) – A boolean indicating whether to assign fixed points to the data. Defaults to False.

  • reversed_fixedpoints (bool) – A boolean indicating whether to reverse the fixed points assignment. Defaults to False.

Raises:
  • ImportError – If the “cdlib” package is not installed and the “louvain” or “leiden” clustering method is specified.

  • ValueError – If an invalid method is specified for calculating the flow of data through the grid.

  • ValueError – If an invalid method is specified for clustering the data into modules.

Return type:

None

Returns:

None, but updates the adata object with the following fields of the adata.uns[“streamline_clusters_” + basis]
  • ”feature_df”

  • ”segments”

  • ”X_pca”

  • ”clustering_method”

  • ”distances”

  • ”connectivities”

  • ”clusters”

  • ”fixed_point”

  • ”rev_fixed_point”