stereo.core.ms_data.MSData.to_integrate#
- MSData.to_integrate(scope, res_key, _from, type='obs', item=None, fill=nan, cluster=True)[source]#
Integrate an obs column or a var column from some single-samples spcified by
_from
to the merged sample.- Parameters:
scope (
slice
) – Which integrate mss group to save result.res_key (
str
) – New column name in merged sample obs or var._from (
slice
) – Where to get the single-sample target infomation.type (
Literal
['obs'
,'var'
]) – obs or var level, defaults to ‘obs’item (
Optional
[list
]) – The column names in single-sample obs or var, defaults to Nonefill – Default value when the merged sample has no conrresponding item, defaults to np.NaN
cluster (
bool
) – Whether it is a clustering result, defaults to True
Note
The length of
scope
must be equal to_from
.The
type
just only supports ‘obs’ now.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()
Integrating an obs column named as ‘celltype’ from first three samples to the merged sample, to name as ‘celltype’
>>> from stereo.core.ms_pipeline import slice_generator >>> ms_data.to_integrate(res_key='celltype', scope=slice_generator[0:3], _from=slice_generator[0:3], type='obs', item=['celltype'] * 3)
Integrating an obs column named as ‘celltype’ from all samples to the merged sample, to name as ‘celltype’
>>> from stereo.core.ms_pipeline import slice_generator >>> ms_data.to_integrate(res_key='celltype', scope=slice_generator[:], _from=slice_generator[:], type='obs', item=['celltype'] * ms_data.num_slice)