multiassayexperiment package¶
Subpackages¶
Submodules¶
multiassayexperiment.MultiAssayExperiment module¶
- class multiassayexperiment.MultiAssayExperiment.MultiAssayExperiment(experiments, column_data=None, sample_map=None, metadata=None, _validate=True)[source]¶
Bases:
BiocObjectContainer class for representing and managing multi-omics genomic experiments.
Checkout the R/MultiAssayExperiment for more information.
- __getitem__(args)[source]¶
Subset a MultiAssayExperiment.
- Parameters:
args (
tuple) –Tuple containing slices along dimensions (rows, columns, experiments).
Each element in the tuple, might be either a integer vector (integer positions), boolean vector or
sliceobject. Defaults to None.- Raises:
ValueError – Too many or too few slices.
- Return type:
- Returns:
A new sliced MultiAssayExperiment object with the subsets.
- __init__(experiments, column_data=None, sample_map=None, metadata=None, _validate=True)[source]¶
Initialize an instance of
MultiAssayExperiment.You may also initialize an
MultiAssayExperimentusingmake_maeor by transform fromfrom_mudataandfrom_anndataobjects.If both
column_dataandsample_mapare None, the constructor naively creates sample mapping, with eachexperimentconsidered to be a independent sample. We add a sample tocol_datain this pattern -unknown_sample_{experiment_name}. All cells from the same experiment are considered to be from the same sample and is reflected insample_map.- Parameters:
experiments (
dict[str,Any]) –A dictionary containing experiments, with experiment names as keys and the experiments as values.
Each
experimentmay be either aSummarizedExperimentor any class that extendsSummarizedExperiment.column_data (
BiocFrame|None) –Bio-specimen/sample information.
column_datamay provide information about patients, cell lines, or other biological units.Each row in this table represents an independent biological unit. It must contain an index that maps to the ‘primary’ in
sample_map.Defaults to None.
sample_map (
BiocFrame|None) –Map biological units from
column_datato the list of experiments.Must contain columns “assay”, “primary”, and “colname”.
- assay provides the names of the different experiments performed on the biological units.
All experiment names from
experimentsmust be present in this column.
- primary contains the sample name. All names in this column must match with row labels from
- colname is the mapping of samples/cells within each experiment back to its biosample information in
Each sample in
column_datamay map to one or more columns per assay.Defaults to None.
metadata (
dict[str,Any] |NamedList|None) – Additional study-level metadata. Defaults to None._validate (
bool) – Internal use only.
- add_experiment(name, experiment, sample_map, column_data=None, in_place=False)[source]¶
Add a new experiment to MultiAssayExperiment.
sample_mapmust be provided to map the columns from this experiment tocolumn_data. This will be appended to the existingsample_map.Optionally,
column_datamay be provided to add new sample information.- Parameters:
name (
str) – Name of the new experiment.experiment (
Any) – The experiment to add.sample_map (
BiocFrame) – Sample map to append to the MAE.column_data (
BiocFrame|None) –Sample data to append to the MAE.
Defaults to None.
in_place (
bool) – Whether to modify theMultiAssayExperimentin place. Defaults to False.
- Return type:
- Returns:
A modified
MultiAssayExperimentobject, either as a copy of the original or as a reference to the (in-place-modified) original.
- property assays: dict[str, Any]¶
Alias for
get_experiments().
- property colnames: dict[str, Names | None]¶
Alias for
get_column_names, provided for back-compatibility.
- property column_data: BiocFrame¶
Alias for
get_column_data().
- property column_names: dict[str, Names | None]¶
Alias for
get_column_names, provided for back-compatibility.
- property columnnames: dict[str, Names | None]¶
Alias for
get_column_names, provided for back-compatibility.
- copy()[source]¶
Alias for
__copy__().
- experiment(name, with_sample_data=False)[source]¶
Get an experiment by name.
- Parameters:
- Raises:
AttributeError – If the experiment name does not exist.
IndexError – If index is greater than the number of experiments.
- Return type:
- Returns:
The experiment object.
If
with_sample_datais True, a copy of the experiment object is returned.
- property experiment_names: list[str]¶
Alias for
get_experiment_names().
- property experiments: dict[str, Any]¶
Alias for
get_experiments().
- classmethod from_anndata(input, name='unknown')[source]¶
Create a
MultiAssayExperimentfromAnnData.Since
AnnDatadoes not contain sample information, sample named"unknown_sample"will be added tocol_data. All cells are considered to be extracted from this sample and is reflected insample_map.- Parameters:
input (anndata.AnnData) – An
AnnDataobject.name (str) –
Name for the experiment.
Defaults to “unknown”.
- Return type:
MultiAssayExperiment
- Returns:
An
MultiAssayExperiment.
- classmethod from_mudata(input)[source]¶
Create a
MultiAssayExperimentobject fromMuData.The import naively creates sample mapping, each
experimentis considered to be a sample. We add a sample with the following pattern -"unknown_sample_{experiment_name}"tocol_data. All cells from the same experiment are considered to be extracted from the same sample and is reflected insample_map.- Parameters:
input (mudata.MuData) – MuData object.
- Raises:
Exception – If
mudataobject is read in backed modeisbacked.- Return type:
MultiAssayExperiment
- Returns:
MultiAssayExperimentobject.
- get_column_data()[source]¶
Get sample metadata.
- Return type:
BiocFrame- Returns:
A
BiocFramecontaining sample metadata.
- get_experiment(name, with_sample_data=False)[source]¶
Alias for
experiment().- Return type:
- get_sample_map()[source]¶
Acess sample map.
- Return type:
BiocFrame- Returns:
A
BiocFramewith sample mapping information.
- get_with_column_data(name)[source]¶
Alias to
experiment().Consistency with Bioconductor’s naming of the same function.
- Return type:
- intersect_rows()[source]¶
Finds common row names across all experiments and filters the MAE to these rows.
- Return type:
- Returns:
A new sliced MultiAssayExperiment object with the filtered rows.
- property rownames: dict[str, Names | None]¶
Alias for
get_row_names, provided for back-compatibility.
- property sample_map: BiocFrame¶
Alias for
get_sample_map().
- set_column_data(column_data, in_place=False)[source]¶
Set new sample metadata.
- Parameters:
column_data (
BiocFrame) – New sample metadata.in_place (
bool) – Whether to modify theMultiAssayExperimentin place.
- Return type:
- Returns:
A modified
MultiAssayExperimentobject, either as a copy of the original or as a reference to the (in-place-modified) original.
- set_experiment_names(names, in_place=False)[source]¶
Replace
experiments’s names.- Parameters:
- Return type:
- Returns:
A modified
MultiAssayExperimentobject, either as a copy of the original or as a reference to the (in-place-modified) original.
- set_experiments(experiments, in_place=False)[source]¶
Set new experiments.
- Parameters:
experiments (
dict[str,Any]) –New experiments to set. A dictionary of experiments with experiment names as keys and the experiments as values.
Each
experimentmay be either aSummarizedExperimentor any class that extendsSummarizedExperiment.in_place (
bool) – Whether to modify theMultiAssayExperimentin place.
- Return type:
- Returns:
A modified
MultiAssayExperimentobject, either as a copy of the original or as a reference to the (in-place-modified) original.
- set_sample_map(sample_map, in_place=False)[source]¶
Set new sample mapping.
- Parameters:
sample_map (
BiocFrame) – New sample map.in_place (
bool) – Whether to modify theMultiAssayExperimentin place.
- Return type:
- Returns:
A modified
MultiAssayExperimentobject, either as a copy of the original or as a reference to the (in-place-modified) original.
- subset_by_column(columns)[source]¶
Subset by column.
- subset_by_experiments(experiments)[source]¶
Subset by experiment(s).
- Parameters:
experiments (
str|int|bool|Sequence) –Experiments to extract.
Integer indices, a boolean filter, or (if the current object is named) names specifying the ranges to be extracted, see
normalize_subscript().Check
experiment_namesfor a list of valid experiment names.- Return type:
- Returns:
A new MultiAssayExperiment with the subset experiments.
- subset_by_row(rows)[source]¶
Subset by rows.
- subset_experiments(rows, columns, experiment_names)[source]¶
Subset experiments.
- Parameters:
rows (
str|int|bool|Sequence|None) –Row indices to subset.
Integer indices, a boolean filter, or (if the current object is named) names specifying the ranges to be extracted, see
normalize_subscript().columns (
str|int|bool|Sequence|None) –Column indices (from
column_data) to subset.Integer indices, a boolean filter, or (if the current object is named) names specifying the ranges to be extracted, see
normalize_subscript().experiment_names (
str|int|bool|Sequence) –Experiment names to keep.
Integer indices, a boolean filter, or (if the current object is named) names specifying the ranges to be extracted, see
normalize_subscript().Check
experiment_namesfor a list of valid experiment names.
- Return type:
- Returns:
A dictionary with experiment names as keys and the subsetted experiment data as value.
- class multiassayexperiment.MultiAssayExperiment.SlicerResult(experiments, sample_map, column_data)¶
Bases:
tuple- __annotations__ = {}¶
- __getnewargs__()¶
Return self as a plain tuple. Used by copy and pickle.
- __match_args__ = ('experiments', 'sample_map', 'column_data')¶
- static __new__(_cls, experiments, sample_map, column_data)¶
Create new instance of SlicerResult(experiments, sample_map, column_data)
- __repr__()¶
Return a nicely formatted representation string
- __slots__ = ()¶
- column_data¶
Alias for field number 2
- experiments¶
Alias for field number 0
- sample_map¶
Alias for field number 1