insitupy.InSituExperiment#
- class insitupy.InSituExperiment#
Class to manage and analyze multiple spatially resolved single-cell transcriptomics experiments.
The class consists of multiple
InSituDatadatasets and associated metadata aspandas.DataFrame. This class provides functionality for managing datasets, performing differential gene expression analysis, querying metadata, visualizing data, and saving/loading experiments.- metadata#
A DataFrame containing metadata for the datasets.
- Type:
pd.DataFrame
- 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.
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
InSituExperimentobject.from_config(config_path[, mode])Create an InSituExperiment object from a configuration file.
from_regions(data, region_key[, region_names])generate_collection(cells_layer[, ...])get_n_cells([cells_layer])iterdata()Iterate over the metadata rows and corresponding data.
load_all([skip])load_images([names, nuclei_type, ...])load_transcripts([transcript_filename])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.
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])Attributes
annotationscellsGet the collection of anndatas.
Get the dataset dictionary.
imagesGet the metadata DataFrame.
Return save path of the InSituExperiment object.
regionstranscripts