rapids_singlecell.pp.scale#
- rapids_singlecell.pp.scale(data, *, zero_center=True (settings.preset='scanpy-v1' – changes in 2.0), max_value=None, use=None, out=False, mask=None, copy=False, layer=None, obsm=None, mask_obs=None, inplace=True)[source]#
Scales matrix to unit variance and clips values
- Parameters:
- data
AnnData|ndarray|csc_matrix|csr_matrix|Array The (annotated) data matrix of shape
n_obs×n_vars. Rows correspond to cells and columns to genes. If a matrix is passed instead of anAnnDataobject, the scaled matrix is returned.- zero_center
bool|Default(default:True (settings.preset='scanpy-v1' – changes in 2.0)) If
False, omit zero-centering variables, which allows to handle sparse input efficiently.- max_value
float|None(default:None) Clip (truncate) to this value after scaling. If
None, do not clip.- use
LayerAcc|MultiAcc|str|None(default:None) Which matrix to scale, e.g.
A.X,A.layers['counts']orA.obsm['x']. Strings are resolved byanndata.acc.AdAcc.resolve(), e.g.'layers.counts'.- out
LayerAcc|MultiAcc|str|ScaleOut|bool(default:False) Where to write the outputs. A single accessor writes
scaledto it, a mapping (ScaleOut) writes only the outputs it names, e.g.{'scaled': A.layers['scaled'], 'mean': A.var['m']}. IfTrue, they are returned as aScaleResult. IfFalse,scaledis written to the placeusereads from andmean/stdto.var['mean']/.var['std'](.var['mean of {mask}']or.var['mean with mask']ifmaskis given; not written ifuseis an.obsmarray).- mask
ndarray|AdRef|str|None(default:None) Restrict both the derivation of scaling parameters and the scaling itself to a certain set of observations: a boolean array or a reference like
A.obs['m'](strings are resolved, e.g.'obs.m'). If the matrix is in csc format and a mask is provided, the matrix will be transformed to csr format.
- data
- Return type:
AnnData|ScaleResult|spmatrix|ndarray|None- Returns:
The scaled matrix if a matrix is passed, a
ScaleResultifout=True, elseNone.