## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set(cache = TRUE, autodep = TRUE, cache.lazy = FALSE) ## ----warning=FALSE, message=FALSE--------------------------------------------- suppressMessages({ library(SpatialExperimentIO) library(SpatialExperiment) }) ## ----eval=FALSE--------------------------------------------------------------- # ### DO NOT RUN. Example code. # xepath <- "/path/to/folder" # # Xenium as SPE, or SCE by setting `returnType = "SCE"`. # xe_spe <- readXeniumSXE(dirName = xepath, # addExperimentXenium = TRUE, addParquetPaths = TRUE, # altExps = c(negprobe="^NegControlProbe", antisense = "^antisense", # negcode="^NegControlCodeword", blank = "^BLANK")) ## ----eval=FALSE--------------------------------------------------------------- # ### DO NOT RUN. Example code. # cospath <- "/path/to/folder" # # CosMx as SPE, or SCE by setting `returnType = "SCE"`. # cos_spe <- readCosmxSXE(dirName = cospath, # loadFovPos = TRUE, addParquetPaths = TRUE, # altExps = c(negprobe="^Neg", falsecode="^Sys")) ## ----eval=FALSE--------------------------------------------------------------- # ### DO NOT RUN. Example code. # merpath <- "/path/to/folder" # # MERSCOPE as SPE, or SCE by setting `returnType = "SCE"`. # mer_spe <- readMerscopeSXE(dirName = merpath) ## ----eval=FALSE--------------------------------------------------------------- # ### DO NOT RUN. Example code. # starpath <- "/path/to/folder" # # STARmapPLUS as SPE, or SCE by setting `returnType = "SCE"`. # star_spe <- readStarmapplusSXE(dirName = starpath) ## ----eval=FALSE--------------------------------------------------------------- # ### DO NOT RUN. Example code. # seqfpath <- "/path/to/folder" # # seqFISH as SPE, or SCE by setting `returnType = "SCE"`. # seqf_spe <- readSeqfishSXE(dirName = merpath) ## ----------------------------------------------------------------------------- xepath <- system.file( file.path("extdata", "Xenium_small"), package = "SpatialExperimentIO") list.files(xepath) ## ----------------------------------------------------------------------------- # # read the count matrix .h5 file - automatically DropletUtils::read10xCounts(type = "HDF5") # xe_spe <- readXeniumSXE(dirName = xe_path, # returnType = "SPE", # countMatPattern = "cell_feature_matrix.h5", # metaDataPattern = "cells.parquet", # coordNames = c("x_centroid", "y_centroid"), # addExperimentXenium = FALSE, # set to TRUE to load experiment.xenium # altExps = NULL, # possible value c(negprobe="^NegControlProbe", antisense = "^antisense", # negcode="^NegControlCodeword", blank = "^BLANK") # addParquetPaths = FALSE, # set TRUE to load all .parquet below # ...) # takes arguments as below # xe_spe <- addParquetPathsXenium(sxe = xe_spe, # dirName = xe_path, # loadTx = TRUE, # txMetaNames = "transcripts", # txPattern = "transcripts.parquet", # loadCellBound = TRUE, # cellBoundMetaNames = "cell_boundaries", # cellBoundPattern = "cell_boundaries.parquet", # loadNucBound = TRUE, # NucBoundMetaNames = "nucleus_boundaries", # NucBoundPattern = "nucleus_boundaries.parquet") xe_spe <- readXeniumSXE(dirName = xepath) xe_spe ## ----------------------------------------------------------------------------- xe_spe <- readXeniumSXE(xepath, addExperimentXenium = TRUE, altExps = c(negprobe="^NegControlProbe", antisense = "^antisense", negcode="^NegControlCodeword", blank = "^BLANK"), addParquetPaths = TRUE, loadTx = FALSE) xe_spe ## ----------------------------------------------------------------------------- # list.files(file.path(xepath, "cell_feature_matrix")) # "barcodes.tsv.gz" "features.tsv.gz" "matrix.mtx.gz" ## ----------------------------------------------------------------------------- # # or read the count matrix folder - automatically DropletUtils::read10xCounts(type = "sparse") # xe_spe <- readXeniumSXE(dirName = xepath, # countMatPattern = "cell_feature_matrix") ## ----------------------------------------------------------------------------- xe_sce <- readXeniumSXE(dirName = xepath, returnType = "SCE") xe_sce ## ----------------------------------------------------------------------------- cospath <- system.file( file.path("extdata", "CosMx_small"), package = "SpatialExperimentIO") list.files(cospath) ## ----------------------------------------------------------------------------- # cos_spe <- readCosmxSXE(dirName = cospath, # returnType = "SPE", # countMatPattern = "exprMat_file.csv", # metaDataPattern = "metadata_file.csv", # coordNames = c("CenterX_global_px", "CenterY_global_px"), # loadFovPos = FALSE, # set to TRUE to add fov position columns to colData() # fovPosPattern = "fov_positions_file.csv", # altExps = NULL, # possible value c(negprobe="^Neg", falsecode="^Sys") # addParquetPaths = FALSE, # set TRUE to load all .parquet below # ...) # takes arguments as below # cos_spe <- addParquetPathsCosMx(sxe = cos_spe, # dirName = cospath, # loadTx = TRUE, # txMetaNames = "transcripts", # txPattern = "tx_file.csv", # loadPolygon = TRUE, # polygonMetaNames = "polygons", # polygonPattern = "polygons.csv") cos_spe <- readCosmxSXE(dirName = cospath) cos_spe ## ----------------------------------------------------------------------------- cos_spe <- readCosmxSXE(cospath, loadFovPos = TRUE, altExps = c(negprobe="^Neg", falsecode="^Sys"), addParquetPaths = TRUE, loadPolygon = FALSE) cos_spe ## ----------------------------------------------------------------------------- cos_sce <- readCosmxSXE(dirName = cospath, returnType = "SCE") cos_sce ## ----------------------------------------------------------------------------- merpath <- system.file( file.path("extdata", "MERSCOPE_small"), package = "SpatialExperimentIO") list.files(merpath) ## ----------------------------------------------------------------------------- # mer_spe <- readMerscopeSXE(dirName = merpath, # returnType = "SPE", # countMatPattern = "cell_by_gene.csv", # metaDataPattern = "cell_metadata.csv", # coordNames = c("center_x", "center_y")) mer_spe <- readMerscopeSXE(dirName = merpath) mer_spe ## ----------------------------------------------------------------------------- mer_sce <- readMerscopeSXE(dirName = merpath, returnType = "SCE") mer_sce ## ----------------------------------------------------------------------------- starpath <- system.file( file.path("extdata", "STARmapPLUS_small"), package = "SpatialExperimentIO") list.files(starpath) ## ----------------------------------------------------------------------------- # readStarmapplusSXE <- function(dirName = dirName, # returnType = "SPE", # countMatPattern = "raw_expression_pd.csv", # metaDataPattern = "spatial.csv", # coordNames = c("X", "Y", "Z")) star_spe <- readStarmapplusSXE(dirName = starpath) star_spe ## ----------------------------------------------------------------------------- star_sce <- readStarmapplusSXE(dirName = starpath, returnType = "SCE") star_sce ## ----------------------------------------------------------------------------- seqfpath <- system.file( file.path("extdata", "seqFISH_small"), package = "SpatialExperimentIO") list.files(seqfpath) ## ----------------------------------------------------------------------------- # seqf_spe <- readSeqfishSXE(dirName = seqfpath, # returnType = "SPE", # countMatPattern = "cell_by_gene.csv", # metaDataPattern = "cell_metadata.csv", # coordNames = c("center_x", "center_y")) seqf_spe <- readSeqfishSXE(dirName = seqfpath) seqf_spe ## ----------------------------------------------------------------------------- seqf_sce <- readSeqfishSXE(dirName = seqfpath, returnType = "SCE") seqf_sce ## ----tidy = TRUE-------------------------------------------------------------- sessionInfo()