scanpy_plus.pp.assign_sex module¶
- scanpy_plus.pp.assign_sex.assign_sex(data, ygenes=None, use_raw=True, download_gencode=False)¶
Assigns sex based on XIST and Y-chromosome gene expression.
This function expects log-normalised input. It adds the following columns to adata.obs:
XIST_logn: log-normalized expression of XIST
Ygene_logn: mean log-normalized expression of the specified Y-chromosome genes
XIST_bin: binary indicator for XIST expression
Ygene_bin: binary indicator for Y gene expression
sex: inferred sex (“male”, “female”, or “ambiguous”)
- Parameters:
data (anndata.AnnData) – Annotated data matrix.
ygenes (list of str or None) – List of Y-chromosome gene names to use. If None: It uses default human chrY list from Ensembl.
use_raw (bool, optional) – Whether to use adata.raw values. Defaults to True.
download_gencode (bool) – Whether to get chrY genes from gencode and use it. Default False. [Time consuming]
- Returns:
Updated AnnData object with sex assignment columns in .obs.
- Return type:
anndata.AnnData
Examples
>>> import scanpy as sc >>> import scanpy_plus as scp >>> scp.pp.assign_sex(adata, ygenes=['Ddx3y', 'Kdm5d'], use_raw=True)