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, if data is the type of StereoExpData and base_adata is not provided, a new Anndata object will be created, if data is the type of AnnBasedStereoExpData, the data.adata is used as the base_adata.

  • 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 (Union[str, List[str], None]) – A path or a list of paths to the images 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, List[int], List[float], None]) – The scale of image for high resolution, default to 4, the size of image will be changed to (image.width * im_hires / 100, image.height * im_hires / 100), the image scaled by im_hires will be added to adata.uns[‘spatial’][im_library_id][‘images’][‘hires’], it can be a single value or a list of values whose length is the same as the number of images, when it is a single value and image is a list of paths, the same value will be applied to all images.

  • im_lowres (Union[int, float, List[int], List[float], None]) – The scale of image for low resolution, default to 1, the size of image will be changed to (image.width * im_lowres / 100, image.height * im_lowres / 100), the image scaled by im_lowres will be added to adata.uns[‘spatial’][im_library_id][‘images’][‘lowres’], it can be a single value or a list of values whose length is the same as the number of images, when it is a single value and image is a list of paths, the same value will be applied to all images.

  • im_library_id (Union[str, List[str], None]) – 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, if image is a list of paths, im_library_id must be a list of the same length.

Return type:

An object of Anndata.