spateo.tools.spatial_correlation¶
Functions¶
|
Calculate global bivariate Moran's I between a spatial variable and gene expression |
|
Calculate global bivariate Moran's I between a spatial variable and gene expression |
Module Contents¶
- spateo.tools.spatial_correlation.spatial_bv_moran_obs_genes(adata: anndata.AnnData, obs_key: str, connectivity_key: str = 'spatial_connectivities', genes: str | int | Sequence[str] | Sequence[int] | None = None, n_neighbors: int = 10, mode: str = 'moran', transformation: str = 'r', permutations: int | None = 999, copy: bool = False) pandas.DataFrame | None[source]¶
Calculate global bivariate Moran’s I between a spatial variable and gene expression
- Parameters:
- adata
AnnData object containing spatial data
- obs_key
Key in adata.obs for the variable
- connectivity_key
Key in adata.obsp for spatial connectivity matrix (default: ‘spatial_connectivities’)
- genes
Genes to calculate (names or indices). If None, use all genes.
- mode
Spatial correlation mode (only ‘moran’ supported)
- transformation
Weight transformation method (‘r’ for row-standardization)
- permutations
Number of permutations for significance testing
- copy
Return a DataFrame instead of storing in AnnData
- Returns:
If
copy = True, returns apandas.DataFramewith the following keys –- Ifloat
value of bivariate Moran’s I
- simarray
(if permutations>0) vector of I values for permuted samples
- p_simfloat
(if permutations>0) p-value based on permutations (one-sided) null: spatial randomness alternative: the observed I is extreme it is either extremely high or extremely low
- z_simarray
(if permutations>0) standardized I based on permutations
- p_z_simfloat
(if permutations>0) p-value based on standard normal approximation from permutations
Otherwise, modifies the
adatawith the following key –anndata.AnnData.uns['{obs_key}_gene_bv_moranI']- the above mentioned dataframe``.
- spateo.tools.spatial_correlation.spatial_bv_local_moran(adata: anndata.AnnData, feature1_key: str, feature2_key: str, connectivity_key: str = 'spatial_connectivities', n_neighbors: int = 10, mode: str = 'moran', transformation: str = 'r', permutations: int | None = 999, copy: bool = False) pandas.DataFrame | None[source]¶
Calculate global bivariate Moran’s I between a spatial variable and gene expression
- Parameters:
- adata
AnnData object containing spatial data
- feature1_key
Key in adata.obs for the first variable or gene_name
- feature2_key
Key in adata.obs for the seconda variable or gene_name
- connectivity_key
Key in adata.obsp for spatial connectivity matrix (default: ‘spatial_connectivities’)
- mode
Spatial correlation mode (only ‘moran’ supported)
- transformation
Weight transformation method (‘r’ for row-standardization)
- permutations
Number of permutations for significance testing
- copy
Return a DataFrame instead of storing in AnnData
- Returns:
If
copy = True, returns apandas.DataFramewith the following keys –- Ifloat
value of bivariate Moran’s I
- qarray
(if permutations>0) values indicate quandrant location 1 HH, 2 LH, 3 LL, 4 HL
- simarray
(if permutations>0) vector of I values for permuted samples
- p_simfloat
(if permutations>0) p-value based on permutations (one-sided) null: spatial randomness alternative: the observed I is extreme it is either extremely high or extremely low
- z_simarray
(if permutations>0) standardized I based on permutations
- p_z_simfloat
(if permutations>0) p-value based on standard normal approximation from permutations
Otherwise, modifies the
adatawith the following key –anndata.AnnData.uns['{feature1_key}_{feature2_key}_bv_local_moranI']- the above mentioned dataframe``.