stereo.core.ms_data.MSData#
- class stereo.core.ms_data.MSData(_data_list=<factory>, _merged_data=None, _names=<factory>, _obs=None, _var=None, _var_type='intersect', _relationship='other', _relationship_info=<factory>, _name_dict=<factory>, _data_dict=<factory>, _MSDataStruct__idx_generator=-1)[source]#
MSData
is a composite structure of severalStereoExpData
organized by some relationship.- Parameters:
data_list (List[StereoExpData]
stereo_exp_data
array) – An array ofstereo_exp_data
organized by some relationship defined by_relationship
and_relationship_info
merged_data (
stereo_exp_data
object) – Anstereo_exp_data
merged withdata_list
used batches integrate.names (List[str]
stereo_exp_data
array’s names) – An array of `stereo_exp_data`s’ unique names.obs (pandas.DataFrame = None) –
pandas.DataFrame
describes all the cells or bins observed, indexes mean cell names or bin names, columns mean some math statistic or types produced by bio-information algorithm.var (pd.DataFrame = None) –
pandas.DataFrame
describes genes, similar to_obs
._var_type (str = 'intersect') – Which claims that
_var
is intersected by lots ofgenes
from different samples.relationship (str = 'other') – Relationship about samples in
_data_list
._relationship_info (object) – Relationship extra info.
tl (object) –
MSData
algorithms collections, include all tools methods inherited fromstereo_exp_data
and multi-samplesmethods. Methods from
stereo_exp_data
will organized with mutilthreads while running.
plt (object) –
MSData
plot methods collections, same astl
.
Examples
Constructing MSData from two `stereo_exp_data`s.
>>> from stereo.io.reader import read_gef >>> from stereo.core.ms_data import MSData >>> data1 = read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.gef") >>> data2 = read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.tissue.gef") >>> ms_data = MSData(_data_list=[data1, data2], _names=['raw', 'tissue'], _relationship='other', _var_type='intersect') # noqa >>> ms_data
ms_data: {‘raw’: (9004, 25523), ‘tissue’: (9111, 20816)} num_slice: 2 names: [‘raw’, ‘tissue’] obs: [‘test_obs_1’] var: [‘test_var_1’] relationship: other var_type: intersect to 20760 tl.result: defaultdict(<class ‘list’>, {})
Constructing MSData one by one using add method.
>>> from stereo.core.ms_data import MSData >>> from stereo.io.reader import read_gef >>> ms_data = MSData() >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.gef") >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.tissue.gef") >>> ms_data ms_data: {'0': (9004, 25523), '1': (9111, 20816)} num_slice: 2 names: ['0', '1'] obs: ['test_obs_1'] var: ['test_var_1'] relationship: other var_type: intersect to 20760 tl.result: defaultdict(<class 'list'>, {})
Slice features like python list.
>>> from stereo.core.ms_data import MSData >>> from stereo.io.reader import read_gef >>> ms_data = MSData() >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.gef") >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.tissue.gef") >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.gef") >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.tissue.gef") >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.gef") >>> ms_data += read_gef("../demo_data/SS200000135TL_D1/SS200000135TL_D1.tissue.gef") >>> ms_data[3:] _MSDataView(_names=['3', '4', '5'], _data_list=[StereoExpData object with n_cells X n_genes = 9111 X 20816 bin_type: bins bin_size: 100 offset_x = 0 offset_y = 2 cells: ['cell_name'] genes: ['gene_name'], ...)
Slice features like DataFrame.
>>> ms_data[('1', '4'):] _MSDataView(_names=['1', '4'], _data_list=[StereoExpData object with n_cells X n_genes = 9111 X 20816 bin_type: bins bin_size: 100 offset_x = 0 offset_y = 2 cells: ['cell_name'] genes: ['gene_name'], ...)
- __init__(_data_list=<factory>, _merged_data=None, _names=<factory>, _obs=None, _var=None, _var_type='intersect', _relationship='other', _relationship_info=<factory>, _name_dict=<factory>, _data_dict=<factory>, _MSDataStruct__idx_generator=-1)#
Methods
__init__
([_data_list, _merged_data, _names, ...])add_data
([data, names])- rtype:
object
del_data
(name)integrate
([reorganize_coordinate])rename
(mapper)- rtype:
object
reset_name
([start_idx, default_key])- rtype:
object
reset_position
([mode])split_after_batching_integrate
()to_integrate
(scope, res_key, _from[, type, ...])Integrate an obs column or a var column from some single-samples spcified by
_from
to the merged sample.to_isolated
(scope, res_key, to[, type, ...])Copy a result from mss group specfied by scope to some single-samples specfied by
to
.to_msdata
(data[, batch_key, relationship, ...])var_percent
()Attributes
data_list
merged_data
mss
names
num_slice
obs
plt
relationship
relationship_info
shape
tl
var