bento.tl.flux

bento.tl.flux(sdata, points_key='transcripts', instance_key='cell_boundaries', feature_key='feature_name', method='radius', n_neighbors=None, radius=None, res=1, train_size=1, random_state=11, recompute=False)

Compute RNAflux embeddings of each pixel as local composition normalized by cell composition. For k-nearest neighborhoods or “knn”, method, specify n_neighbors. For radius neighborhoods, specify radius. The default method is “radius” with radius = 1/4 of cell radius. RNAflux requires a minimum of 4 genes per cell to compute all embeddings properly.

Parameters:
  • sdata (SpatialData) – Spatial formatted SpatialData object.

  • points_key (str) – key for points element that holds transcript coordinates

  • instance_key (str) – Key for cell_boundaries instances

  • feature_key (str) – Key for gene instances

  • method (str) – Method to use for local neighborhood. Either ‘knn’ or ‘radius’.

  • n_neighbors (int) – Number of neighbors to use for local neighborhood.

  • radius (float) – Fraction of mean cell radius to use for local neighborhood.

  • res (float) – Resolution to use for rendering embedding.

Returns:

sdata

.points[“{instance_key}_raster”]: pd.DataFrame

Length pixels DataFrame containing all computed flux values, embeddings, and colors as columns in a single DataFrame. flux values: <gene_name> for each gene used in embedding. embeddings: flux_embed_<i> for each component of the embedding. colors: hex color codes for each pixel.

.table.uns[“flux_genes”]list

List of genes used for embedding.

.table.uns[“flux_variance_ratio”]np.ndarray

[components] array of explained variance ratio for each component.

Return type:

SpatialData