spateo.tools.spatial_degs ========================= .. py:module:: spateo.tools.spatial_degs .. autoapi-nested-parse:: Spatial DEGs Functions --------- .. autoapisummary:: spateo.tools.spatial_degs.moran_i spateo.tools.spatial_degs.cellbin_morani Module Contents --------------- .. py:function:: moran_i(adata: anndata.AnnData, genes: Optional[List[str]] = None, layer: Optional[str] = None, spatial_key: str = 'spatial', model: Literal['2d', '3d'] = '2d', x: Optional[List[int]] = None, y: Optional[List[int]] = None, z: Optional[List[int]] = None, k: int = 5, weighted: Optional[List[str]] = None, permutations: int = 199, n_jobs: int = 1) -> pandas.DataFrame Identify genes with strong spatial autocorrelation with Moran's I test. This can be used to identify genes that are potentially related to cluster. :param adata: an Annodata object :type adata: :class:`~anndata.AnnData` :param genes: The list of genes that will be used to subset the data for dimension reduction and clustering. If `None`, all genes will be used. :type genes: `list` or None (default: `None`) :param layer: The layer that will be used to retrieve data for dimension reduction and clustering. If `None`, .X is used. :type layer: `str` or None (default: `None`) :param spatial_key: :type spatial_key: The key in ``.obsm`` that corresponds to the spatial coordinate of each cell. :param x: x-coordinates of all buckets. :type x: 'list' or None(default: `None`) :param y: y-coordinates of all buckets. :type y: 'list' or None(default: `None`) :param z: z-coordinates of all buckets. :type z: 'list' or None(default: `None`) :param k: Number of neighbors to use by default for kneighbors queries. :type k: 'int' (defult=20) :param weighted: Spatial weights, defult is None, 'kernel' is based on kernel functions. :type weighted: 'str'(defult='kernel') :param permutations: Number of random permutations for calculation of pseudo-p_values. :type permutations: `int` (default=999) :param n_cores: The maximum number of concurrently running jobs, If -1 all CPUs are used. If 1 is given, no parallel computing code is used at all. :type n_cores: `int` (default=30) :rtype: A pandas DataFrame of the Moran' I test results. .. py:function:: cellbin_morani(adata_cellbin: anndata.AnnData, binsize: int, cluster_key: str = 'Celltype') -> pandas.DataFrame Calculate Moran's I score for each celltype (in segmented cell adata). Since the presentation of cells are boolean values, this function first summarizes the number of each celltype using a given binsize, creating a spatial 2D matrix with cell counts. Then calculates Moran's I score on the matrix for spatial score for each celltype. :param adata_cellbin: An Annodata object for segmented cells. :type adata_cellbin: :class:`~anndata.AnnData` :param binsize: The binsize used to summarize cell counts for each celltype. :type binsize: int :param cluster_key: The key in adata.obs including celltype labels. :type cluster_key: `str` (default="Celltype") :rtype: A pandas DataFrame containing the Moran' I score for celltypes.