readVizgen: Read Vizgen MERFISH output as SpatialFeatureExperiment

View source: R/read.R

readVizgenR Documentation

Read Vizgen MERFISH output as SpatialFeatureExperiment

Description

This function reads the standard Vizgen MERFISH output into an SFE object. The coordinates are in microns. Cell centroids are read into colGeometry "centroids", and cell segmentations are read into colGeometry "cellSeg". The image(s) (polyT and DAPI) are also read as SpatRaster objects so they are not loaded into memory unless necessary. Because the image's origin is the top left while the geometry's origin is bottom left, either the image or the geometry needs to be flipped. Because the image accompanying MERFISH datasets are usually very large, the coordinates will be flipped so the flipping operation won't load the entire image into memory.

Usage

readVizgen(
  data_dir,
  z = 3L,
  use_cellpose = TRUE,
  sample_id = "sample01",
  min_area = 15,
  image = c("DAPI", "PolyT"),
  flip = c("geometry", "image", "none"),
  max_flip = "50 MB",
  BPPARAM = SerialParam()
)

Arguments

data_dir

Top level directory of Vizgen output, which contains directories cell_boundaries and images, and files cell_by_gene.csv, cell_metadata.csv, and detected_transcripts.csv.

z

Index of z plane to read.

use_cellpose

Logical, whether to use Cellpose parquet files if present.

sample_id

A character sample identifier, which matches the sample_id in imgData. The sample_id will also be stored in a new column in colData, if not already present. Default = sample01.

min_area

Minimum cell area in square microns. Anything smaller will be considered artifact or debris and removed.

image

Which image(s) to load, can be "DAPI", "PolyT", or both.

flip

To flip the image, geometry coordinates, or none. Because the image has the origin at the top left while the geometry has origin at the bottom left, one of them needs to be flipped for them to match. If one of them is already flipped, then use "none". The image will not be flipped if it's GeoTIFF.

max_flip

Maximum size of the image allowed to flip the image. Because the image will be loaded into memory to be flipped. If the image is larger than this size then the coordinates will be flipped instead.

BPPARAM

A BiocParallelParam object specifying parallel processing backend and number of threads to use to load cell segmentation from HDF5 files from different fields of view (FOVs) with multiple cores. A progress bar can be configured in the BiocParallelParam object. When there are numerous FOVs, reading in the geometries can be time consuming, so we recommend using a server and larger number of threads. This argument is not used if use_cellpose = TRUE and the parquet file is present.

Value

A SpatialFeatureExperiment object.

Examples

dir_use <- system.file("extdata/vizgen", package = "SpatialFeatureExperiment")
sfe <- readVizgen(dir_use, z = 0L, use_cellpose = TRUE, image = "PolyT",
flip = "geometry")

pachterlab/SpatialFeatureExperiment documentation built on March 11, 2024, 11:11 p.m.