spateo.preprocessing.transform ============================== .. py:module:: spateo.preprocessing.transform .. autoapi-nested-parse:: Miscellaneous non-normalizing data transformations on AnnData objects Functions --------- .. autoapisummary:: spateo.preprocessing.transform.log1p spateo.preprocessing.transform.log1p_sparse spateo.preprocessing.transform.log1p_array spateo.preprocessing.transform.log1p_anndata spateo.preprocessing.transform.scale spateo.preprocessing.transform.scale_sparse spateo.preprocessing.transform.scale_array spateo.preprocessing.transform.scale_anndata spateo.preprocessing.transform._get_mean_var spateo.preprocessing.transform.sparse_mean_variance_axis spateo.preprocessing.transform.sparse_mean_var_minor_axis spateo.preprocessing.transform.sparse_mean_var_major_axis Module Contents --------------- .. py:function:: log1p(X: Union[anndata.AnnData, numpy.ndarray, scipy.sparse.spmatrix], base: Optional[int] = None, copy: bool = False) Computes the natural logarithm of the data matrix (unless different base is chosen using the `base` argument) :param X: Either full AnnData object or .X. Rows correspond to cells and columns to genes. :param base: Natural log is used by default. :param copy: If an :class:`~anndata.AnnData` is passed, determines whether a copy is returned. :param layer: Layer to transform. If None, will transform .X. If given both argument to `layer` and `obsm`, argument to `layer` will take priority. :param obsm: Entry in .obsm to transform. If None, will transform .X. :returns: If `copy` is True or input is numpy array/sparse matrix, returns updated data array. Otherwise, returns updated AnnData object. .. py:function:: log1p_sparse(X, *, base: Optional[int] = None, copy: bool = False) Called if `log1p` is called with a sparse matrix input. .. py:function:: log1p_array(X, *, base: Optional[int] = None, copy: bool = False) Called if `log1p` is called with a numpy array input .. py:function:: log1p_anndata(adata, *, base: Optional[int] = None, copy: bool = False, layer: Optional[str] = None, obsm: Optional[str] = None) -> Optional[anndata.AnnData] Called if `log1p` is called with an AnnData input .. py:function:: scale(X: Union[anndata.AnnData, scipy.sparse.spmatrix, numpy.ndarray], zero_center: bool = True, max_value: Optional[float] = None, copy: bool = False, layer: Optional[str] = None, obsm: Optional[str] = None, return_mean_std: bool = False) Scale variables to unit variance and optionally zero mean. Variables that are constant across all observations will be set to 0. :param X: Either full AnnData object or .X. Rows correspond to cells and columns to genes. :param zero_center: If False, will not center variables. :param max_value: Truncate to this value after scaling. :param copy: If an :class:`~anndata.AnnData` is passed, determines whether a copy is returned. :param layer: Layer to transform. If None, will transform .X. If given both argument to `layer` and `obsm`, argument to `layer` will take priority. :param obsm: Entry in .obsm to transform. If None, will transform .X. :param return_mean_std: Set True to return computed feature means and feature standard deviations. :returns: Depending on `copy` returns or updates `adata` with a scaled `adata.X`, annotated with `'mean'` and `'std'` in `adata.var`. .. py:function:: scale_sparse(X, *, zero_center: bool = True, max_value: Optional[float] = None, copy: bool = False, return_mean_std: bool = False) Called if `log1p` is called with a sparse matrix input .. py:function:: scale_array(X, *, zero_center: bool = True, max_value: Optional[float] = None, copy: bool = False, return_mean_std: bool = False) Called if `log1p` is called with a numpy array input .. py:function:: scale_anndata(adata: anndata.AnnData, *, zero_center: bool = True, max_value: Optional[float] = None, copy: bool = False, layer: Optional[str] = None, obsm: Optional[str] = None) -> Optional[anndata.AnnData] Called if scale is called with an AnnData object .. py:function:: _get_mean_var(X, *, axis=0) Wrapper for computing row-wise or column-wise mean+variance on sparse array-likes. .. py:function:: sparse_mean_variance_axis(mtx: scipy.sparse.spmatrix, axis: int) Mean and variance of sparse array. :param mtx: scipy.sparse.csr_matrix or scipy.sparse.csc_matrix :param axis: int Either 0 or 1. Determines which axis mean and variance are computed along .. py:function:: sparse_mean_var_minor_axis(data, indices, major_len, minor_len, dtype) Given array for a csr matrix, returns means and variances for each column. .. py:function:: sparse_mean_var_major_axis(data, indices, indptr, major_len, minor_len, dtype) Given array for a csc matrix, returns means and variances for each row.