The VisiumIO package provides a set of functions to import 10X
Genomics Visium experiment data into a SpatialExperiment object. The
package makes use of the SpatialExperiment data structure, which
provides a set of classes and methods to handle spatially resolved
transcriptomics data.
TENxIO Supported Formats
Extension
Class
Imported as
.h5
TENxH5
SingleCellExperiment w/ TENxMatrix
.mtx / .mtx.gz
TENxMTX
SummarizedExperiment w/ dgCMatrix
.tar.gz
TENxFileList
SingleCellExperiment w/ dgCMatrix
peak_annotation.tsv
TENxPeaks
GRanges
fragments.tsv.gz
TENxFragments
RaggedExperiment
.tsv / .tsv.gz
TENxTSV
tibble
VisiumIO Supported Formats
Extension
Class
Imported as
spatial.tar.gz
TENxSpatialList
DataFrame list *
.parquet
TENxSpatialParquet
tibble *
Note. (*) Intermediate format
Installation
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("VisiumIO")
Loading package
library(VisiumIO)
TENxVisium
The TENxVisium class is used to import a single sample of 10X
Visium data. The TENxVisium constructor function takes the following
arguments:
The resource argument is the path to the 10X Visium file. The
spatialResource argument is the path to the 10X Visium spatial file.
It usually ends in spatial.tar.gz.
Example from SpatialExperiment
Note that we use the images = "lowres" and processing = "raw"
arguments based on the name of the tissue_*_image.png file and
*_feature_bc_matrix folder in the spaceranger output. The directory
structure for a single sample is shown below:
The TENxVisiumList class is used to import multiple samples of 10X
Visium. The interface is a bit more simple in that you only need to
provide the space ranger output folder as input to the function.
The sampleFolders argument is a character vector of paths to the
spaceranger output folder. Note that each folder must contain an
outs directory. The sample_ids argument is a character vector of
sample ids.
Example from SpatialExperiment
The directory structure for multiple samples (section1 and
section2) is shown below:
The main inputs to TENxVisiumList are the sampleFolders and
sample_ids. These correspond to the spaceranger output sample
folders and a vector of sample identifiers, respectively.
sample_dirs <- list.dirs(
system.file(
file.path("extdata", "10xVisium"), package = "VisiumIO"
),
recursive = FALSE, full.names = TRUE
)
vlist <- TENxVisiumList(
sampleFolders = sample_dirs,
sample_ids = basename(sample_dirs),
processing = "raw",
images = "lowres"
)
vlist
#> An object of class "TENxVisiumList"
#> Slot "VisiumList":
#> List of length 2
Importing into SpatialExperiment
The import method combines both SingleCellExperiment objects along
with the spatial information into a single SpatialExperiment object.
The number of columns in the SpatialExperiment object is equal to the
number of cells across both samples (section1 and section2).
Introduction
The
VisiumIOpackage provides a set of functions to import 10X Genomics Visium experiment data into aSpatialExperimentobject. The package makes use of theSpatialExperimentdata structure, which provides a set of classes and methods to handle spatially resolved transcriptomics data.TENxIO Supported Formats
VisiumIO Supported Formats
Note. (*) Intermediate format
Installation
Loading package
TENxVisium
The
TENxVisiumclass is used to import a single sample of 10X Visium data. TheTENxVisiumconstructor function takes the following arguments:The
resourceargument is the path to the 10X Visium file. ThespatialResourceargument is the path to the 10X Visium spatial file. It usually ends inspatial.tar.gz.Example from SpatialExperiment
Note that we use the
images = "lowres"andprocessing = "raw"arguments based on the name of thetissue_*_image.pngfile and*_feature_bc_matrixfolder in thespacerangeroutput. The directory structure for a single sample is shown below:Creating a TENxVisium instance
Using the example data in
SpatialExperiment, we can load thesection1sample usingTENxVisium.The show method of the
TENxVisiumclass displays the object’s metadata.Importing into SpatialExperiment
The
TEnxVisiumobject can be imported into aSpatialExperimentobject using theimportfunction.TENxVisiumList
The
TENxVisiumListclass is used to import multiple samples of 10X Visium. The interface is a bit more simple in that you only need to provide thespace rangeroutput folder as input to the function.The
sampleFoldersargument is a character vector of paths to thespacerangeroutput folder. Note that each folder must contain anoutsdirectory. Thesample_idsargument is a character vector of sample ids.Example from SpatialExperiment
The directory structure for multiple samples (
section1andsection2) is shown below:Creating a TENxVisiumList
The main inputs to
TENxVisiumListare thesampleFoldersandsample_ids. These correspond to thespacerangeroutput sample folders and a vector of sample identifiers, respectively.Importing into SpatialExperiment
The
importmethod combines bothSingleCellExperimentobjects along with the spatial information into a singleSpatialExperimentobject. The number of columns in the SpatialExperiment object is equal to the number of cells across both samples (section1andsection2).Visium HD folder structure
The directory structure for a single bin size is shown below.
Import Visium HD into SpatialExperiment
In-package example
By default, the MatrixMarket format is read in (
format = "mtx").H5 files are supported via the
format = "h5"argument input.Click to expand
sessionInfo()Session Info