multiassayexperiment package

Subpackages

Submodules

multiassayexperiment.MultiAssayExperiment module

class multiassayexperiment.MultiAssayExperiment.MultiAssayExperiment(experiments, column_data=None, sample_map=None, metadata=None, validate=True)[source]

Bases: object

Container class for representing and managing multi-omics genomic experiments.

Checkout the R/MultiAssayExperiment for more information.

__copy__()[source]
Returns:

A shallow copy of the current MultiAssayExperiment.

__deepcopy__(memo=None, _nil=[])[source]
Returns:

A deep copy of the current MultiAssayExperiment.

__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 slice object. Defaults to None.

Raises:

ValueError – Too many or too few slices.

Return type:

MultiAssayExperiment

Returns:

A new sliced MultiAssayExperiment object with the subsets.

__repr__()[source]
Return type:

str

Returns:

A string representation.

add_experiment(name, experiment, sample_map, column_data=None, in_place=False)[source]

Add a new experiment to MultiAssayExperiment.

sample_map must be provided to map the columns from this experiment to column_data. This will be appended to the existing sample_map.

Optionally, column_data may 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 (Optional[BiocFrame]) –

    Sample data to append to the MAE.

    Defaults to None.

  • in_place (bool) – Whether to modify the MultiAssayExperiment in place. Defaults to False.

Return type:

MultiAssayExperiment

Returns:

A modified MultiAssayExperiment object, 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.

complete_cases()[source]

Identify samples that have data across all experiments.

Return type:

Sequence[bool]

Returns:

A boolean vector same as the number of samples in ‘column_data’, where each element is True if sample is present in all experiments or False.

copy()[source]

Alias for __copy__().

experiment(name, with_sample_data=False)[source]

Get an experiment by name.

Parameters:
  • name (Union[int, str]) – Name or index position of the experiment.

  • with_sample_data (bool) –

    Whether to merge column data of the experiment with sample_data from the MAE.

    Defaults to False.

Raises:
  • AttributeError – If the experiment name does not exist.

  • IndexError – If index is greater than the number of experiments.

Return type:

Any

Returns:

The experiment object.

If with_sample_data is 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().

find_common_row_names()[source]

Finds common row names across all experiments.

Return type:

List[str]

classmethod from_anndata(input, name='unknown')[source]

Create a MultiAssayExperiment from AnnData.

Since AnnData does not contain sample information, sample named "unknown_sample" will be added to col_data. All cells are considered to be extracted from this sample and is reflected in sample_map.

Parameters:
  • input (anndata.AnnData) – An AnnData object.

  • name (str) –

    Name for the experiment.

    Defaults to “unknown”.

Return type:

MultiAssayExperiment

Returns:

An MultiAssayExperiment.

classmethod from_mudata(input)[source]

Create a MultiAssayExperiment object from MuData.

The import naively creates sample mapping, each experiment is considered to be a sample. We add a sample with the following pattern - "unknown_sample_{experiment_name}" to col_data. All cells from the same experiment are considered to be extracted from the same sample and is reflected in sample_map.

Parameters:

input (mudata.MuData) – MuData object.

Raises:

Exception – If mudata object is read in backed mode isbacked.

Return type:

MultiAssayExperiment

Returns:

MultiAssayExperiment object.

get_column_data()[source]

Get sample metadata.

Return type:

BiocFrame

Returns:

A BiocFrame containing sample metadata.

get_column_names()[source]
Return type:

Dict[str, Optional[Names]]

Returns:

Dictionary, with experiment names as keys, and the column names as values.

get_experiment_names()[source]

Get experiment names.

Return type:

List[str]

Returns:

List of experiment names.

get_experiments()[source]

Access experiments.

Return type:

Dict[str, Any]

Returns:

A dictionary of all experiments, with experiment names as keys and experiment data as value.

get_metadata()[source]
Return type:

dict

Returns:

Dictionary of metadata for this object.

get_row_names()[source]
Return type:

Dict[str, Optional[Names]]

Returns:

Dictionary, with experiment names as keys, and row names as values.

get_sample_map()[source]

Acess sample map.

Return type:

BiocFrame

Returns:

A BiocFrame with sample mapping information.

get_with_column_data(name)[source]

Alias to experiment().

Consistency with Bioconductor’s naming of the same function.

Return type:

Any

intersect_rows()[source]

Finds common row names across all experiments and filters the MAE to these rows.

Return type:

MultiAssayExperiment

Returns:

A new sliced MultiAssayExperiment object with the filtered rows.

property metadata: dict

Alias for get_metadata.

replicated()[source]

Identify samples with replicates within each experiment.

Return type:

Dict[str, Dict[str, Sequence[bool]]]

Returns:

A dictionary where experiment names are keys and values specify if the sample is replicated within each experiment.

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 the MultiAssayExperiment in place.

Return type:

MultiAssayExperiment

Returns:

A modified MultiAssayExperiment object, 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:
  • names (List[str]) – New names.

  • in_place (bool) – Whether to modify the MultiAssayExperiment in place.

Return type:

MultiAssayExperiment

Returns:

A modified MultiAssayExperiment object, 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 experiment may be either a SummarizedExperiment or any class that extends SummarizedExperiment.

  • in_place (bool) – Whether to modify the MultiAssayExperiment in place.

Return type:

MultiAssayExperiment

Returns:

A modified MultiAssayExperiment object, either as a copy of the original or as a reference to the (in-place-modified) original.

set_metadata(metadata, in_place=False)[source]

Set additional metadata.

Parameters:
  • metadata (dict) – New metadata for this object.

  • in_place (bool) – Whether to modify the MultiAssayExperiment in place.

Return type:

MultiAssayExperiment

Returns:

A modified MultiAssayExperiment object, 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 the MultiAssayExperiment in place.

Return type:

MultiAssayExperiment

Returns:

A modified MultiAssayExperiment object, 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.

Parameters:

columns (Union[str, int, bool, Sequence]) –

Columns to be extracted.

Integer indices, a boolean filter, or (if the current object is named) names specifying the ranges to be extracted, see normalize_subscript().

Return type:

MultiAssayExperiment

Returns:

A new MultiAssayExperiment with the subsetted columns.

subset_by_experiments(experiments)[source]

Subset by experiment(s).

Parameters:

experiments (Union[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_names for a list of valid experiment names.

Return type:

MultiAssayExperiment

Returns:

A new MultiAssayExperiment with the subset experiments.

subset_by_row(rows)[source]

Subset by rows.

Parameters:

rows (Union[str, int, bool, Sequence]) –

Rows to be extracted.

Integer indices, a boolean filter, or (if the current object is named) names specifying the ranges to be extracted, see normalize_subscript().

Return type:

MultiAssayExperiment

Returns:

A new MultiAssayExperiment with the subsetted rows.

subset_experiments(rows, columns, experiment_names)[source]

Subset experiments.

Parameters:
  • rows (Union[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 (Union[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 (Union[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_names for a list of valid experiment names.

Return type:

Dict[str, Any]

Returns:

A dictionary with experiment names as keys and the subsetted experiment data as value.

to_mudata()[source]

Transform MultiAssayExperiment object to MuData.

Returns:

A MuData representation.

class multiassayexperiment.MultiAssayExperiment.SlicerResult(experiments, sample_map, column_data)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

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

Module contents