stereo.core.ms_data.MSData.to_isolated¶
- MSData.to_isolated(scope, res_key, to, type='obs', item=None, fill=nan)[source]¶
Copy a result from mss group specfied by scope to some single-samples specfied by
to.- Parameters:
scope (
slice) – Which integrate mss group to get result.res_key (
str) – the key to get result from mms group.to (
slice) – which single-samples are the result copy to.type (
Literal['obs','var']) – obs or var level, defaults to ‘obs’item (
Union[list,ndarray,str,None]) – New column name in obs of single-sample, defaults to the value ofres_key.fill – Default value when the single-sample has no conrresponding item, defaults to np.NaN
Note
The length of
scopemust be equal toto.Only supports clustering result when
typeis ‘obs’ and hvg result whentypeis ‘var’.Parameter
itemonly available for obs type.Examples
Constructing MSData from 5 single-samples.
>>> import stereo as st >>> data1 = st.io.read_h5ad('../data/10.h5ad') >>> data2 = st.io.read_h5ad('../data/11.h5ad') >>> data3 = st.io.read_h5ad('../data/12.h5ad') >>> data4 = st.io.read_h5ad('../data/13.h5ad') >>> data5 = st.io.read_h5ad('../data/14.h5ad') >>> ms_data = data1 + data2 + data3 + data4 + data5 >>> ms_data ms_data: {'0': (493, 30254), '1': (285, 30254), '2': (753, 30254), '3': (731, 30254), '4': (412, 30254)} num_slice: 5 names: ['0', '1', '2', '3', '4'] obs: [] var: [] relationship: other var_type: intersect to 0 mss: []
Integrating all samples to a merged one.
>>> ms_data.integrate()
… did a clustering, the key of result is ‘leiden’ …
Copy the ‘leiden’ result to first three samples, to name as ‘leiden’.
>>> from stereo.core.ms_pipeline import slice_generator >>> ms_data.to_isolated(scope=slice_generator[0:3], res_key='leiden', to=slice_generator[0:3], type='obs', item=['leiden'] * 3)
Copy the ‘leiden’ result to all samples, to name as ‘leiden’.
>>> from stereo.core.ms_pipeline import slice_generator >>> ms_data.to_isolated(scope=slice_generator[:], res_key='leiden', to=slice_generator[:], type='obs', item=['leiden'] * 3)