ehrapy.preprocessing.subsample¶
- ehrapy.preprocessing.subsample(data, fraction=None, n_obs=None, random_state=0, copy=False)[source]¶
Subsample to a fraction of the number of observations.
- Parameters:
data (
Union
[AnnData
,ndarray
,spmatrix
]) – The (annotated) data matrix of shape n_obs × n_vars. Rows correspond to observations (patients) and columns to features.fraction (
Optional
[float
], default:None
) – Subsample to this fraction of the number of observations.n_obs (
Optional
[int
], default:None
) – Subsample to this number of observations.random_state (
Union
[int
,RandomState
,None
], default:0
) – Random seed to change subsampling.copy (
bool
, default:False
) – If anAnnData
is passed, determines whether a copy is returned.
- Return type:
- Returns:
Returns X[obs_indices], obs_indices if data is array-like, otherwise subsamples the passed
AnnData
(copy == False) or returns a subsampled copy of it (copy == True).