## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----libs, message = FALSE----------------------------------------------------
library(MultiAssaySpatialExperiment)
library(SummarizedExperiment)
library(S4Vectors)

## ----construct_minimal--------------------------------------------------------
mat <- matrix(rnorm(20), nrow = 5, ncol = 4,
  dimnames = list(paste0("Gene", 1:5), paste0("Cell", 1:4)))

pts <- DataFrame(
  x = c(1.2, 2.5, 3.1, 4.8),
  y = c(1.5, 2.3, 3.7, 4.2),
  instance_id = paste0("Cell", 1:4))

mase <- MultiAssaySpatialExperiment(
  experiments = ExperimentList(rna = mat),
  colData = DataFrame(row.names = paste0("Cell", 1:4)),
  sampleMap = DataFrame(
    assay = factor("rna", "rna"),
    primary = paste0("Cell", 1:4),
    colname = paste0("Cell", 1:4)
  ),
  points = PointsLayerList(coords = pts),
  spatialMap = DataFrame(
    assay = factor("rna", "rna"),
    colname = paste0("Cell", 1:4),
    element_type = "points",
    region = factor("coords", "coords"),
    instance_id = paste0("Cell", 1:4)
  )
)

mase

## ----anatomy_inherited--------------------------------------------------------
experiments(mase)
colData(mase)
sampleMap(mase)

## ----anatomy_spatial----------------------------------------------------------
spatialPoints(mase)
spatialPoints(mase)[["coords"]]

# empty in this minimal object, but the accessors always exist
spatialShapes(mase)
spatialImages(mase)

## ----anatomy_spatialmap-------------------------------------------------------
spatialMap(mase)

## ----mase_erd, echo = FALSE, out.width = "100%", fig.cap = "Entity-relationship diagram of the MASE schema. Tan entities are inherited from MultiAssayExperiment; blue entities are added by MASE."----
knitr::include_graphics("mase_erd.png")

## ----sessionInfo--------------------------------------------------------------
sessionInfo()

