cellink.utils.dosage_per_strand#
- cellink.utils.dosage_per_strand(adata)#
Convert dosage to per-strand encoding.
This function takes the dosage data in
adataand converts it into a per-strand encoding format. If the dosage is 0, 1, or 2, it returns standard one-hot encoding. For other dosages, it returns the relative proportion of the dosage.Params#
- adata
The annotated data matrix of shape
n_obsxn_vars. Rows correspond to individuals and columns to variants.
- rtype:
- returns:
Returns the per-strand encoded genotypes or updates
adatawith the new representation, depending oninplace.
Example
>>> import numpy as np >>> from anndata import AnnData >>> adata = AnnData( ... np.array( ... [ ... [0, 1, 2], ... [1, 1, 2], ... [3, 4, 0], ... ] ... ) ... ) >>> per_strand_encoded = dosage_per_strand(adata, key_added="dosage", inplace=False) >>> per_strand_encoded array([[[1. , 0. ], [0.5, 0.5], [1. , 0. ]],
- [[0.5, 0.5],
[0.5, 0.5], [1. , 0. ]],
- [[0.75, 0.25],
[0.8, 0.2], [0. , 1. ]]])