Read and load in MERFISH data from Vizgen-formatted files

ReadVizgen(
  data.dir,
  transcripts = NULL,
  spatial = NULL,
  molecules = NULL,
  type = "segmentations",
  mol.type = "microns",
  metadata = NULL,
  filter = NA_character_,
  z = 3L
)

LoadVizgen(data.dir, fov, assay = "Vizgen", z = 3L)

Arguments

data.dir

Path to the directory with Vizgen MERFISH files; requires at least one of the following files present:

  • cell_by_gene.csv”: used for reading count matrix

  • cell_metadata.csv”: used for reading cell spatial coordinate matrices

  • detected_transcripts.csv”: used for reading molecule spatial coordinate matrices

transcripts

Optional file path for counts matrix; pass NA to suppress reading counts matrix

spatial

Optional file path for spatial metadata; pass NA to suppress reading spatial coordinates. If spatial is provided and type is “segmentations”, uses dirname(spatial) instead of data.dir to find HDF5 files

molecules

Optional file path for molecule coordinates file; pass NA to suppress reading spatial molecule information

type

Type of cell spatial coordinate matrices to read; choose one or more of:

  • “segmentations”: cell segmentation vertices; requires hdf5r to be installed and requires a directory “cell_boundaries” within data.dir. Within “cell_boundaries”, there must be one or more HDF5 file named “feature_data_##.hdf5

  • “centroids”: cell centroids in micron coordinate space

  • “boxes”: cell box outlines in micron coordinate space

mol.type

Type of molecule spatial coordinate matrices to read; choose one or more of:

  • “pixels”: molecule coordinates in pixel space

  • “microns”: molecule coordinates in micron space

metadata

Type of available metadata to read; choose zero or more of:

  • “volume”: estimated cell volume

  • “fov”: cell's fov

filter

A character to filter molecules by, pass NA to skip molecule filtering

z

Z-index to load; must be between 0 and 6, inclusive

fov

Name to store FOV as

assay

Name to store expression matrix as

Value

ReadVizgen: A list with some combination of the following values:

  • transcripts”: a sparse matrix with expression data; cells are columns and features are rows

  • segmentations”: a data frame with cell polygon outlines in three columns: “x”, “y”, and “cell”

  • centroids”: a data frame with cell centroid coordinates in three columns: “x”, “y”, and “cell”

  • boxes”: a data frame with cell box outlines in three columns: “x”, “y”, and “cell”

  • microns”: a data frame with molecule micron coordinates in three columns: “x”, “y”, and “gene”

  • pixels”: a data frame with molecule pixel coordinates in three columns: “x”, “y”, and “gene”

  • metadata”: a data frame with the cell-level metadata requested by metadata

LoadVizgen: A Seurat object

Note

This function requires the data.table package to be installed

Progress Updates with progressr

This function uses progressr to render status updates and progress bars. To enable progress updates, wrap the function call in with_progress or run handlers(global = TRUE) before running this function. For more details about progressr, please read vignette("progressr-intro")

Parallelization with future

This function uses future to enable parallelization. Parallelization strategies can be set using plan. Common plans include “sequential” for non-parallelized processing or “multisession” for parallel evaluation using multiple R sessions; for other plans, see the “Implemented evaluation strategies” section of ?future::plan. For a more thorough introduction to future, see vignette("future-1-overview")