swiftcnv.cnv_score#
- cnv_score(adata, obsm_key='cnv_mat_arms', key_added='cnv_score', inplace=False)#
Calculate CNV burden as the mean of the CNV scores squared.
\[S_i = \frac{1}{M} \sum_{j=1}^{M} x_{ij}^2\]Where:
\(S_i\) is the CNV burden score for cell \(i\) (stored in
adata.obs[key_added]).\(M\) is the total number of features (columns in
adata.obsm[obsm_key]).\(x_{ij}\) represents the CNV value for feature \(j\) in cell \(i\).
- Parameters:
adata (anndata.AnnData) – Input AnnData object.
obsm_key (str, default 'cnv_mat_arms') – Key of the obsm layer to summarise.
key_added (str, default 'cnv_score') –
adata.obskey under which to add the CNV scores.inplace (bool, default False) – Whether to place calculated metrics in
.obsor return them.
- Returns:
If
inplace=False, returns a 1D numpy array with calculated CNV scores. Ifinplace=True, updatesadata.obs[key_added]- Return type:
numpy.ndarray or anndata.AnnData