insitupy.InSituExperiment

insitupy.InSituExperiment#

class insitupy.InSituExperiment#

A class to manage and analyze multiple spatially resolved single-cell transcriptomics experiments.

../../_images/insituexperiment_overview.svg

This class provides functionality for managing datasets, performing differential gene expression analysis, querying metadata, visualizing data, and saving/loading experiments. It operates on multiple datasets, each represented as an InSituData object, and maintains associated metadata in a pandas.DataFrame.

Examples

>>> # Create an InSituExperiment object
>>> experiment = InSituExperiment()
>>> # Add a dataset
>>> experiment.add(data="path/to/dataset", mode="insitupy", metadata={"experiment": "test"})
>>> # Perform differential gene expression analysis
>>> experiment.dge(target_id=0, ref_id=1, target_annotation_tuple=("cell_type", "neuron"))
>>> # Save the experiment
>>> experiment.saveas("path/to/save", overwrite=True)
>>> # Query the experiment
>>> subset = experiment.query({"experiment": ["test"]})
>>> # Plot UMAPs
>>> experiment.plot_umaps(color="cell_type", title_column="experiment")
__init__()#

Initialize an InSituExperiment object.

Methods

__init__()

Initialize an InSituExperiment object.

add(data[, mode, metadata])

Add a dataset to the experiment and update metadata.

add_metadata_column(column_name, values)

append_metadata(new_metadata, by[, overwrite])

Append metadata to the existing InSituExperiment object.

collect_anndatas(*args, **kwargs)

concat(objs[, new_col_name])

Concatenate multiple InSituExperiment objects.

copy()

Create a deep copy of the InSituExperiment object.

dge(target_id[, ref_id, ...])

Wrapper function for performing differential gene expression analysis within an InSituExperiment object.

from_config(config_path[, mode])

Create an InSituExperiment object from a configuration file.

from_regions(data, region_key[, region_names])

Creates an InSituExperiment object from specified regions in the given InSituData.

get_n_cells([cells_layer])

Get the total number of cells across all datasets.

import_from_anndata(adata, uid_column, ...)

Import observation and observation matrix data from an AnnData object into the experiment.

import_obs(*args, **kwargs)

iterdata()

Iterate over the metadata rows and corresponding data.

load_all([skip])

Load all data modalities for all datasets.

load_annotations()

load_cells()

load_images([names, nuclei_type, ...])

load_regions()

load_transcripts([transcript_filename])

plot_embedding(basis[, cells_layer, color, ...])

Create a plot with embeddings of all datasets as subplots using scanpy's sc.pl.embedding function.

plot_overview(*args, **kwargs)

plot_umaps([cells_layer, color, ...])

Create a plot with UMAPs of all datasets as subplots using scanpy's pl.umap function.

query(criteria)

Query the experiment based on metadata criteria.

read(path)

Read an InSituExperiment object from a specified folder.

remove_history()

remove_metadata_columns(columns)

Remove specified columns from the internal metadata.

save([verbose, overwrite_metadata, ...])

saveas(path[, overwrite, verbose])

Save all datasets to a specified folder.

show(index[, verbose])

Displays the dataset at the specified index.

show_modality(modality[, uid_column])

sync_colors(keys[, cells_layer, palette, ...])

Synchronize color dictionaries for categorical metadata across datasets.

to_anndata([cells_layer, label_col, ...])

Concatenate all datasets into a single AnnData object.

Attributes

annotations

Displays a summary of the 'annotations' modality for all datasets.

cells

Displays a summary of cells for all datasets.

colors

Color dictionaries created by sync_colors().

data

List of datasets as InSituData objects.

images

Displays a summary of the 'images' modality for all datasets.

metadata

Returns a copy of the experiment-level metadata.

path

Save path of the InSituExperiment object.

regions

Displays a summary of the 'regions' modality for all datasets.

transcripts

Displays a summary of the 'transcripts' modality for all datasets.