MoleculeExperiment class: An S4 class container to store imaging-based spatial transcriptomics data.
Source:R/AllClasses.R
, R/MoleculeExperiment.R
MoleculeExperiment.Rd
This class enables the analysis of imaging-based ST data at the molecule level, and standardises data across vendors. The aim of this class is to facilitate ST data integration and comparison and, importantly, facilitate common analytical and visualisation workflows.
Arguments
- molecules
Detected transcripts information in a standardised ME list format, as is generated by dataframeToMEList() and readMolecules() functions.
- boundaries
Slot with boundary information in a standardised ME list format, as is generated by dataframeToMEList() and readBoundaries() functions.
Slots
molecules
Slot containing information about the detected transcripts. This slot is designed as a list of lists, where each sample contains a list of tibbles with information for each gene. The basic information required for this slot are the gene names of the transcripts, as well as their x and y locations.
boundaries
Slot containing the boundaries defining each segmented cell. The slot is designed as a list of lists, where each sample contains a list of tibbles for each cell, consisting of the x and y coordinates of the polygon vertices defining the cell boundary.
Examples
# creating a simple ME object from toy data
moleculesDf <- data.frame(
sample_id = rep(c("sample1", "sample2"), times = c(30, 20)),
features = rep(c("gene1", "gene2"), times = c(20, 30)),
x_coords = runif(50),
y_coords = runif(50)
)
boundariesDf <- data.frame(
sample_id = rep(c("sample1", "sample2"), times = c(16, 6)),
cell_id = rep(c("cell1", "cell2", "cell3", "cell4",
"cell1", "cell2"),
times = c(4, 4, 4, 4, 3, 3)),
vertex_x = rnorm(22),
vertex_y = rnorm(22)
)
moleculesMEList <- dataframeToMEList(moleculesDf,
dfType = "molecules",
assayName = "detected",
sampleCol = "sample_id",
factorCol = "features",
xCol = "x_coords",
yCol = "y_coords")
boundariesMEList <- dataframeToMEList(boundariesDf,
dfType = "boundaries",
assayName = "cell",
sampleCol = "sample_id",
factorCol = "cell_id",
xCol = "vertex_x",
yCol = "vertex_y")
toyME <- MoleculeExperiment(molecules = moleculesMEList,
boundaries = boundariesMEList)
toyME
#> MoleculeExperiment class
#>
#> molecules slot (1): detected
#> - detected:
#> samples (2): sample1 sample2
#> -- sample1:
#> ---- features (2): gene1 gene2
#> ---- molecules (30)
#> ---- location range: [0.05,0.99] x [0.01,0.99]
#> -- sample2:
#> ---- features (1): gene2
#> ---- molecules (20)
#> ---- location range: [0.03,0.9] x [0.02,0.95]
#>
#>
#> boundaries slot (1): cell
#> - cell:
#> samples (2): sample1 sample2
#> -- sample1:
#> ---- segments (4): cell1 cell2 cell3 cell4
#> -- sample2:
#> ---- segments (2): cell1 cell2