insitupy.InSituData#

class insitupy.InSituData(path=None, metadata=None, slide_id=None, sample_id=None)#

InSituData class for managing and analyzing spatially resolved transcriptomics data.

../_images/insitudata_overview.svg

It provides methods for loading, saving, visualizing, and manipulating various modalities of data, such as images, cells, annotations, regions, and transcripts.

images#

Image data associated with the object.

Type:

ImageData

cells#

Cell data associated with the object.

Type:

MultiCellData

annotations#

Annotation data associated with the object.

Type:

AnnotationsData

regions#

Region data associated with the object.

Type:

RegionsData

transcripts#

Transcript data associated with the object.

Type:

pd.DataFrame

path#

Path to the data directory.

Type:

Union[str, os.PathLike, Path]

metadata#

Metadata associated with the InSituData object.

Type:

dict

slide_id#

Identifier for the slide.

Type:

str

sample_id#

Identifier for the sample.

Type:

str

from_insitudata#

Indicates whether the object was loaded from an InSituData project.

Type:

bool

viewer#

Napari viewer for visualizing the data.

Type:

napari.Viewer

quicksave_dir#

Experimental feature! Directory for quicksave operations.

Type:

Path

__init__(path, metadata, slide_id, sample_id, from_insitudata)#

Initializes an InSituData object.

__repr__()#

Returns a string representation of the object.

assign_geometries(geometry_type, keys, add_masks, add_to_obs, overwrite, cells_layer)#

Assigns geometries (annotations or regions) to the cell data.

assign_annotations(keys, add_masks, overwrite)#

Assigns annotations to the cell data.

assign_regions(keys, add_masks, overwrite)#

Assigns regions to the cell data.

copy(keep_path)#

Creates a deep copy of the InSituData object.

crop(region_tuple, xlim, ylim, inplace, verbose)#

Crops the data based on the provided parameters.

plot_dimred(save)#

Plots dimensionality reduction results.

load_all(skip, verbose)#

Loads all available modalities.

load_annotations(verbose)#

Loads annotation data.

import_annotations(files, keys, scale_factor, verbose)#

Imports annotation data from external files.

load_regions(verbose)#

Loads region data.

import_regions(files, keys, scale_factor, verbose)#

Imports region data from external files.

load_cells(verbose)#

Loads cell data.

load_images(names, overwrite, verbose)#

Loads image data.

load_transcripts(verbose, mode)#

Loads transcript data.

read(path)#

Reads an InSituData object from a specified folder.

saveas(path, overwrite, zip_output, images_as_zarr, zarr_zipped, images_max_resolution, verbose)#

Saves the InSituData object to a specified path.

save(path, zarr_zipped, verbose, keep_history)#

Saves the InSituData object to its current path or a specified path.

save_colorlegends(savepath, from_canvas, max_per_row)#

Saves color legends from the viewer.

quicksave(note)#

Experimental feature! Saves a quick snapshot of the annotations.

list_quicksaves()#

Experimental feature! Lists all available quicksaves.

load_quicksave(uid)#

Experimental feature! Loads a quicksave by its unique identifier.

show(keys, cells_layer, point_size, scalebar, unit, grayscale_colormap, return_viewer, widgets_max_width)#

Visualizes the data using a napari viewer.

store_geometries(name_pattern, uid_col)#

Extracts geometric layers from the viewer and stores them as annotations or regions.

plot_expr_along_obs_val(keys, obs_val, cells_layer, groupby, method, stderr, savepath, return_data, **kwargs)#

Plots expression values along an observation value.

reload(skip, verbose)#

Reloads the loaded modalities.

get_loaded_modalities()#

Returns a list of currently loaded modalities.

remove_history(verbose)#

Removes the history of saved modalities.

remove_modality(modality)#

Removes a specific modality from the object.

__init__(path=None, metadata=None, slide_id=None, sample_id=None)#

Methods

__init__([path, metadata, slide_id, sample_id])

add_alt(*args, **kwargs)

add_baysor(*args, **kwargs)

assign_annotations([keys, cells_layers, ...])

assign_geometries(geometry_type[, keys, ...])

Function to assign geometries (annotations or regions) to the anndata object in InSituData.cells[layer].matrix.

assign_regions([keys, cells_layers, ...])

copy([keep_path])

Function to generate a deep copy of the InSituData object.

crop([region_tuple, xlim, ylim, inplace, ...])

Crop the data based on the provided parameters.

get_loaded_modalities()

get_modality(modality)

import_annotations(files, keys, scale_factor)

import_regions(files, keys, scale_factor[, ...])

list_quicksaves()

load_all([skip, verbose])

load_annotations([verbose])

load_cells([verbose])

load_images([names, overwrite, verbose])

load_quicksave(uid)

load_regions([verbose])

load_transcripts([verbose, mode])

normalize_and_transform(*args, **kwargs)

plot_dimred([save])

Read dimensionality reduction plots.

plot_expr_along_obs_val(keys, obs_val[, ...])

quicksave([note])

read(path)

Read an InSituData object from a specified folder.

read_all(*args, **kwargs)

read_annotations(*args, **kwargs)

read_cells(*args, **kwargs)

read_images(*args, **kwargs)

read_regions(*args, **kwargs)

read_transcripts(*args, **kwargs)

reduce_dimensions(*args, **kwargs)

reload([skip, verbose])

remove_history([verbose])

remove_modality(modality)

save([path, zarr_zipped, verbose, keep_history])

save_colorlegends([savepath, from_canvas, ...])

save_current_colorlegend(*args, **kwargs)

saveas(path[, overwrite, zip_output, ...])

Function to save the InSituData object.

show([keys, cells_layer, point_size, ...])

store_geometries([name_pattern, uid_col])

Extracts geometric layers from shapes and points layers in the napari viewer and stores them in the InSituData object as annotations or regions.

Attributes

annotations

Return annotations of the InSituData object.

cells

Return cell data of the InSituData object.

from_insitudata

images

Return images of the InSituData object.

metadata

Return metadata of the InSituData object.

path

Return save path of the InSituData object.

regions

Return regions of the InSituData object.

sample_id

Return sample id of the InSituData object.

slide_id

Return slide id of the InSituData object.

transcripts

Return transcripts of the InSituData object.

viewer

Return viewer of the InSituData object.