readCosMX | R Documentation |
This function reads the standard CosMX output into an SFE object, as in "Basic Data Files" on the Nanostring website.
readCosMX(
data_dir,
z = "all",
sample_id = "sample01",
add_molecules = FALSE,
split_cell_comps = FALSE,
BPPARAM = SerialParam(),
file_out = file.path(data_dir, "tx_spots.parquet"),
z_option = c("3d", "split")
)
data_dir |
Top level output directory. |
z |
Integer z index or "all" to indicate which z-planes to read for the transcript spots. |
sample_id |
A |
add_molecules |
Logical, whether to add transcripts coordinates to an object. |
split_cell_comps |
Logical, whether to split transcript spot geometries by cell compartment. Only relevant when 'add_molecules = TRUE'. |
BPPARAM |
A
|
file_out |
Name of file to save the geometry or raster to disk. Especially when the geometries are so large that it's unwieldy to load everything into memory. If this file (or directory for multiple files) already exists, then the existing file(s) will be read, skipping the processing. When writing the file, extensions supplied are ignored and extensions are determined based on 'dest'. |
z_option |
What to do with z coordinates. "3d" is to construct 3D geometries. "split" is to create a separate 2D geometry for each z-plane so geometric operations are fully supported but some data wrangling is required to perform 3D analyses. When the z coordinates are not integers, 3D geometries will always be constructed since there are no z-planes to speak of. This argument does not apply when 'spatialCoordsNames' has length 2. |
An SFE object. Cell polygons are written to 'cell_boundaries_sf.parquet' in 'data_dir'. If reading transcript spots ('add_molecules = TRUE'), then the reformatted transcript spots are saved to file specified in the 'file_out' argument, which is by default 'tx_spots.parquet' in the same directory as the rest of the data.
fp <- tempdir()
dir_use <- SFEData::CosMXOutput(file_path = file.path(fp, "cosmx_test"))
sfe <- readCosMX(dir_use, z = "all", add_molecules = TRUE)
# Clean up
unlink(dir_use, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.