Giotto import functionalities for CosMx datasets. This function generates a `CosmxReader` instance that has convenient reader functions for converting individual pieces of CosMx data into Giotto-compatible representations when the params `cosmx_dir` and `fovs` (if only a subset is desired) are provided. A function that creates the full `giotto` object is also available. These functions should have all param values provided as defaults, but can be flexibly modified to do things such as look in alternative directories or paths.

importCosMx(
  cosmx_dir = NULL,
  slide = 1,
  fovs = NULL,
  micron = FALSE,
  px2mm = 0.12028
)

Arguments

cosmx_dir

CosMx output directory

slide

numeric. Slide number. Defaults to 1

fovs

numeric. (optional) If provided, will load specific fovs. Otherwise, all FOVs will be loaded

micron

logical. Whether to scale spatial information as micron instead of the default pixels

px2mm

numeric. Scalefactor from pixels to mm. Defaults to 0.12028 based on `CosMx-ReadMe.html` info

Value

CosmxReader object

Details

Loading functions are generated after the `cosmx_dir` is added. Transcripts, expression, and metadata loading are all expected to be done from the top level of the directory. Loading of polys, and any image sets are expected to be from specific subdirectories containing only those images for the set of FOVs.

Examples

# Create a `CosmxReader` object
reader <- importCosMx()

if (FALSE) { # \dontrun{
# Set the cosmx_dir and fov parameters
reader$cosmx_dir <- "path to cosmx dir"
reader$fov <- c(1, 4)

plot(reader) # displays FOVs (top left corner) in px scale.

# Load polygons, transcripts, and images
polys <- reader$load_polys()
tx <- reader$load_transcripts()
imgs <- reader$load_images()

# Create a `giotto` object and add the loaded data
g <- giotto()
g <- setGiotto(g, tx[["rna"]])
g <- setGiotto(g, polys)
g <- addGiottoLargeImage(g, largeImages = imgs)
force(g)
} # }