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.
It provides methods for loading, saving, visualizing, and manipulating various modalities of data, such as images, cells, annotations, regions, and transcripts.
- cells#
Cell data associated with the object.
- Type:
- annotations#
Annotation data associated with the object.
- Type:
- regions#
Region data associated with the object.
- Type:
- transcripts#
Transcript data associated with the object.
- Type:
pd.DataFrame
- path#
Path to the data directory.
- Type:
Union[str, os.PathLike, Path]
- 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_modality(modality)import_annotations(files, keys, scale_factor)import_regions(files, keys, scale_factor[, ...])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(*args, **kwargs)sync_geometries()Attributes
Return annotations of the InSituData object.
Return cell data of the InSituData object.
Return images of the InSituData object.
Return metadata of the InSituData object.
Return save path of the InSituData object.
Return regions of the InSituData object.
Return sample id of the InSituData object.
Return slide id of the InSituData object.
Return transcripts of the InSituData object.
Return viewer of the InSituData object.