insitupy.InSituExperiment#

class insitupy.InSituExperiment#

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

../_images/insituexperiment_overview.svg

The class consists of multiple InSituData datasets and associated metadata as pandas.DataFrame. This class provides functionality for managing datasets, performing differential gene expression analysis, querying metadata, visualizing data, and saving/loading experiments.

data#

A list of datasets in the experiment.

Type:

list

metadata#

A DataFrame containing metadata for the datasets.

Type:

pd.DataFrame

path#

The save path of the InSituExperiment object.

Type:

str

collection#

Experimental feature! A collection of AnnData objects.

Type:

anndata.experimental.AnnCollection

__repr__()#

Provides a string representation of the InSituExperiment object.

__getitem__(key)#

Retrieves a subset of the experiment based on the provided key.

__len__()#

Returns the number of datasets in the experiment.

collection()#

Returns the collection of AnnData objects.

data()#

Returns the list of datasets.

metadata()#

Returns a copy of the metadata DataFrame.

path()#

Returns the save path of the InSituExperiment object.

_check_obs_uniqueness(cells_layer=None)#

Checks if observation names are unique across all datasets.

add(data, mode='insitupy', metadata=None)#

Adds a dataset to the experiment and updates metadata.

append_metadata(new_metadata, by=None, overwrite=False)#

Appends metadata to the existing InSituExperiment object.

copy()#

Creates a deep copy of the InSituExperiment object.

dge(target_id, ref_id=None, target_annotation_tuple=None, ...)#

Performs differential gene expression analysis.

iterdata()#

Iterates over the metadata rows and corresponding data.

generate_collection(cells_layer=None, label_col='uid')#

Generates a collection of AnnData objects.

get_n_cells(cells_layer=None)#

Returns the total number of cells across all datasets.

load_all(skip=None)#

Loads all data modalities for all datasets.

load_annotations()#

Loads annotations for all datasets.

load_cells()#

Loads cell data for all datasets.

load_images(names="all", nuclei_type="mip", ...)#

Loads images for all datasets.

load_regions()#

Loads regions for all datasets.

load_transcripts(transcript_filename='transcripts.parquet')#

Loads transcript data for all datasets.

plot_umaps(cells_layer=None, color=None, title_columns=None, ...)#

Creates a plot with UMAPs of all datasets as subplots.

query(criteria)#

Queries the experiment based on metadata criteria.

concat(objs, new_col_name=None)#

Concatenates multiple InSituExperiment objects.

read(path)#

Reads an InSituExperiment object from a specified folder.

from_config(config_path, mode='insitupy')#

Creates an InSituExperiment object from a configuration file.

from_regions(data, region_key, region_names=None)#

Creates an InSituExperiment object from regions of a dataset.

remove_history()#

Removes the history of all datasets.

save(verbose=False, overwrite_metadata=True, **kwargs)#

Saves the InSituExperiment object to its current path.

saveas(path, overwrite=False, verbose=False, **kwargs)#

Saves the InSituExperiment object to a specified path.

show(index, return_viewer=True)#
__init__()#

Initialize an InSituExperiment object.

Methods

__init__()

Initialize an InSituExperiment object.

add(data[, mode, metadata])

Add a dataset to the experiment and update metadata.

append_metadata(new_metadata[, by, overwrite])

Append metadata to the existing InSituExperiment object.

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

concat(objs[, new_col_name])

Concatenate multiple InSituExperiment objects.

copy()

Create a deep copy of the InSituExperiment object.

create_color_dict(obs_col[, cells_layer, ...])

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])

get_n_cells([cells_layer])

import_obs(adata, uid_column, uid_column_adata)

Imports observation and observation matrix data from an AnnData object to the current InSituExperiment.

iterdata()

Iterate over the metadata rows and corresponding data.

load_all([skip])

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 UMAPs of all datasets as subplots using scanpy's pl.umap 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()

save([verbose, overwrite_metadata])

saveas(path[, overwrite, verbose])

Save all datasets to a specified folder.

show(index[, return_viewer])

Displays the dataset at the specified index.

show_modality(modality[, uid_column])

sync_colors(obs_cols[, cells_layer, palette])

Attributes

annotations

cells

collection

Get the collection of anndatas.

data

Get the dataset dictionary.

images

metadata

Get the metadata DataFrame.

path

Return save path of the InSituExperiment object.

regions

transcripts