sparrow.io.merscope#
- sparrow.io.merscope(path, to_coordinate_system='global', z_layers=3, backend=None, transcripts=True, mosaic_images=True, do_3D=False, z_projection=False, imread_kwargs=mappingproxy({}), image_models_kwargs=mappingproxy({}), filter_gene_names=None, output=None)#
Read MERSCOPE data from Vizgen.
Wrapper around
spatialdata_io.merscope, but with support to read in the data as 3D(z,y,x)or perform a z-projection, and with support for reading multiple samples into one spatialdata object This function reads the following files:{ms.TRANSCRIPTS_FILE!r}: Transcript file.mosaic_**_z*.tifimages inside the{ms.IMAGES_DIR!r}directory.
- Parameters:
path (
str|Path|list[str] |list[Path]) – Path to the region/root directory containing the Merscope files (e.g.,detected_transcripts.csv). This can either be a single path or a list of paths, where each path corresponds to a different experiment/roi.to_coordinate_system (
str|list[str] (default:'global')) – The coordinate system to which the elements will be added for each item in path. If provided as a list, its length should be equal to the number of paths specified inpath.z_layers (
int|list[int] |None(default:3)) – Indices of the z-layers to consider. Either oneintindex, or a list ofintindices. IfNone, then no image is loaded. By default, only the middle layer is considered (that is, layer 3).backend (
Optional[Literal['dask_image','rioxarray']] (default:None)) – Either"dask_image"or"rioxarray"(the latter uses less RAM, but requiresrioxarrayto be installed). By default, uses"rioxarray"if and only if therioxarraylibrary is installed.transcripts (
bool(default:True)) – Whether to read transcripts.mosaic_images (
bool(default:True)) – Whether to read the mosaic images.do_3D (
bool(default:False)) – Read the mosaic images and the transcripts as 3D.z_projection (
bool(default:False)) – Perform a z projection (maximum intensity along the z-stacks) on z-stacks of mosaic images.imread_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Keyword arguments to pass to the image reader.image_models_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Keyword arguments to pass to the image models.filter_gene_names (
str|list[str] (default:None)) – Gene names that need to be filtered out (viastr.contains), mostly control genes that were added, and which you don’t want to use. Filtering is case insensitive. Also seesparrow.read_transcripts.output (
str|Path|None(default:None)) – The path where the resultingSpatialDataobject will be backed. IfNone, it will not be backed to a zarr store.
- Raises:
AssertionError – Raised when the number of elements in
pathandto_coordinate_systemare not the same.AssertionError – If elements in
to_coordinate_systemare not unique.ValueError – If both
do_3Dasz_projectionare set toTrue.
- Return type:
SpatialData- Returns:
: A SpatialData object.