stereo.io.stereo_to_anndata

stereo.io.stereo_to_anndata(data, flavor='scanpy', sample_id='sample', reindex=False, output=None, base_adata=None, split_batches=True, compression='gzip', image=None, im_hires=4, im_lowres=1, im_library_id=None)[source]

Transform the StereoExpData object into Anndata format.

Parameters:
  • data (StereoExpData) – the input StereoExpData object.

  • flavor (Literal['scanpy', 'seurat']) – if you want to convert the output file into h5ad of Seurat, please set 'seurat'.

  • sample_id (str) – the sample name which will be set as orig.ident in obs.

  • reindex (bool) – if True, the cell index will be reindexed as {sample_id}:{position_x}_{position_y} format.

  • output (Optional[str]) – the path to output h5ad file.

  • base_adata (Optional[AnnData]) – the input Anndata object.

  • split_batches (bool) – Whether to save each batch to a single file if it is a merged data, default to True.

  • compression (Optional[Literal['gzip', 'lzf']]) – The compression method to be used when saving data as a h5ad file, None means uncompressed, default to gzip.

  • image (Optional[str]) – The path of the register.tif to be added to adata.uns[‘spatial’][im_library_id], the size of image will be changed by im_hires and im_lowres, it can be a grayscale image, a RGB image or a RGBA image.

  • im_hires (Union[int, float, None]) – The scale of image for high resolution, default to 4, the size of image will be changed to (image.height * im_hires / 100, image.width * im_hires / 100), this image will be added to adata.uns[‘spatial’][im_library_id][‘images’][‘hires’].

  • im_lowres (Union[int, float, None]) – The scale of image for low resolution, default to 1, the size of image will be changed to (image.height * im_lowres / 100, image.width * im_lowres / 100), this image will be added to adata.uns[‘spatial’][im_library_id][‘images’][‘lowres’].

  • im_library_id (Optional[str]) – The id of image library, image will be added to adata.uns[‘spatial’][im_library_id], it must be set while image is not None.

Return type:

An object of Anndata.