1 Introduction

This report includes stats and segment/ROI Figures of the Human Brain Nanostring GeoMx Digital Spatial (DSP) data.

Nanostring offers a set of R packages that enables visualization of the GeoMx DSP data and, visit the SpatialOmicsOverlay vignettes for more information. Nanostring generously developed the package for the community and is actively working on it to implement and bring more functionalities. If you have any issues or suggestions, please leave them on the SpatialOmicsOverlay GitHub repo.

2 Prerequisite

2.1 Environment

  • Software: R (v4.3.1)
  • Pakcages:
    • GeomxTools (v3.4.0)
    • SpatialOmicsOverlay (v1.0.0)

2.2 GeoMx DSP Data

  • Sample, N=1: Out of the five samples, the following one sample was selected because the TIFF file size was the smallest, 5.74 GB
Run date Slide (Individual) Sample Autopsy date Sex Age
SEP 01, 2021 hu_brain_004b 81084A (Hippocampus) SEP 04, 2020 M 75
  • Ethnicity: Caucasian
  • Diagnosis: Non-disease normal tissue
  • Sample type: FFPE
  • Segment, N=4: Neuron â—¼, Iba1 â—¼, Neuropil â—¼, Full â—¼
  • Files: OME.TIFF and Lab Worksheet are under the Images, and LabWorksheet folders, respectivley
WORKING_DIRECTORY
├── Images
│   └── *.ome.tiff
└── LabWorksheet
    └── *_LabWorksheet.txt

3 GeoMx DSP Data Visualization

3.1 Preparation

  • Set working directory to load files
# Do not run
baseDir <- "WORKING_DIRECTORY" # where the Images/LabWorksheet folders are located
setwd(baseDir)
library(SpatialOmicsOverlay)
library(GeomxTools)

3.2 Compile a SpatilOverlay object

  • Load OME.TIFF and Lab Worksheet files and export to a SpatialOverlay (SO) object, e.g., soSet.RDS
tiffFile <- file.path(baseDir, "Images", "hu_brain_004b.ome.tiff")
labWorksheet <- file.path(baseDir, "LabWorksheet", "01SEPT2021_HWTA_20210929T1939_LabWorksheet.txt")
lwAnnot <- readLabWorksheet(lw = labWorksheet, slideName = "hu_brain_004b")

soObj <- readSpatialOverlay(ometiff = tiffFile, annots = labWorksheet, 
                              slideName = gsub(".ome.tiff", "", basename(tiffFile)), 
                              image = FALSE, # will load the image later
                              saveFile = FALSE, outline = FALSE)
soObj
## SpatialOverlay 
## Slide Name: hu_brain_004b 
## Overlay Data: 21 samples 
##    Overlay Names: DSP-1009880000092-G-A02 ... DSP-1009880000092-G-B10 ( 21 total ) 
## Scan Metadata 
##    Panels: Human NGS Whole Transcriptome Atlas RNA 
##    Segmentation: Segmented 
## Outline: FALSE
slideName(soObj)
## [1] "hu_brain_004b"
sampNames(soObj)
##  [1] "DSP-1009880000092-G-A02" "DSP-1009880000092-G-A04"
##  [3] "DSP-1009880000092-G-A03" "DSP-1009880000092-G-A05"
##  [5] "DSP-1009880000092-G-A08" "DSP-1009880000092-G-A06"
##  [7] "DSP-1009880000092-G-A07" "DSP-1009880000092-G-A09"
##  [9] "DSP-1009880000092-G-A10" "DSP-1009880000092-G-A11"
## [11] "DSP-1009880000092-G-A12" "DSP-1009880000092-G-B01"
## [13] "DSP-1009880000092-G-B02" "DSP-1009880000092-G-B03"
## [15] "DSP-1009880000092-G-B04" "DSP-1009880000092-G-B05"
## [17] "DSP-1009880000092-G-B06" "DSP-1009880000092-G-B07"
## [19] "DSP-1009880000092-G-B09" "DSP-1009880000092-G-B08"
## [21] "DSP-1009880000092-G-B10"
meta(overlay(soObj))
##    ROILabel               Sample_ID Height Width     X     Y Segmentation
## 1       001 DSP-1009880000092-G-A02   1375  1619 13247  5970    Segmented
## 2       001 DSP-1009880000092-G-A04   1375  1619 13247  5970    Segmented
## 3       001 DSP-1009880000092-G-A03   1375  1619 13247  5970    Segmented
## 4       002 DSP-1009880000092-G-A05   1271  1527 12420  7442    Geometric
## 5       003 DSP-1009880000092-G-A08   1271  1527 12958  8746    Segmented
## 6       003 DSP-1009880000092-G-A06   1271  1527 12958  8746    Segmented
## 7       003 DSP-1009880000092-G-A07   1271  1527 12958  8746    Segmented
## 8       004 DSP-1009880000092-G-A09   1968  1642 14776  3874    Geometric
## 9       005 DSP-1009880000092-G-A10   1232  1650 16539  3519    Segmented
## 10      005 DSP-1009880000092-G-A11   1232  1650 16539  3519    Segmented
## 11      005 DSP-1009880000092-G-A12   1232  1650 16539  3519    Segmented
## 12      006 DSP-1009880000092-G-B01   1113   332 18510 10008    Geometric
## 13      007 DSP-1009880000092-G-B02   1240   384 18638  8362    Geometric
## 14      008 DSP-1009880000092-G-B03    808  1069 20887  8330    Geometric
## 15      009 DSP-1009880000092-G-B04   1969  1527 19982  9052    Segmented
## 16      009 DSP-1009880000092-G-B05   1969  1527 19982  9052    Segmented
## 17      010 DSP-1009880000092-G-B06   1969  1527 19263 11231    Segmented
## 18      010 DSP-1009880000092-G-B07   1969  1527 19263 11231    Segmented
## 19      011 DSP-1009880000092-G-B09   1969  1527 20214 13445    Segmented
## 20      011 DSP-1009880000092-G-B08   1969  1527 20214 13445    Segmented
## 21      012 DSP-1009880000092-G-B10   1271  1527 13507 10070    Geometric
head(coords(soObj))
##                  sampleID ycoor xcoor
## 1 DSP-1009880000092-G-A02  7144 13256
## 2 DSP-1009880000092-G-A02  7145 13256
## 3 DSP-1009880000092-G-A02  7146 13256
## 4 DSP-1009880000092-G-A02  7147 13256
## 5 DSP-1009880000092-G-A02  7148 13256
## 6 DSP-1009880000092-G-A02  7149 13256

3.3 Generating a Figure without image

  • ROIs will be plotted without the tissue image
  • Colors are by default Sample_ID (AOIs)
  • Check the original tissue image from the Nanostring GeoMx DSP instrument
plotSpatialOverlay(overlay = soObj, hiRes = FALSE, legend = FALSE, scaleBar = FALSE)

3.4 Check the level of gene expression

  • Visualize one of the DEGs (Hippocampus up-regulated) and color the segments by the expression level
  • Assign plotting factor(s) to the SO object
    • Segment from Lab Worksheet
    • HPCA expression from the 08_GeoMxSet_AnalysisReady.RDS file
geomxObj <- readRDS(file.path(outDir, "08_GeoMxSet_AnalysisReady.RDS"))

soObj <- addPlottingFactor(overlay = soObj, annots = lwAnnot, plottingFactor = "segment")
soObj <- addPlottingFactor(overlay = soObj, annots = geomxObj, plottingFactor = "HPCA")
soObj <- addPlottingFactor(overlay = soObj, annots = 1:length(sampNames(soObj)), plottingFactor = "ROILabel")
soObj
## SpatialOverlay 
## Slide Name: hu_brain_004b 
## Overlay Data: 21 samples 
##    Overlay Names: DSP-1009880000092-G-A02 ... DSP-1009880000092-G-B10 ( 21 total ) 
## Scan Metadata 
##    Panels: Human NGS Whole Transcriptome Atlas RNA 
##    Segmentation: Segmented 
## Plotting Factors: 
##    varLabels: segment HPCA ROILabel 
## Outline: FALSE
head(plotFactors(soObj))
##                          segment HPCA ROILabel
## DSP-1009880000092-G-A02   Neuron 1078        1
## DSP-1009880000092-G-A04 Neuropil  475        2
## DSP-1009880000092-G-A03     Iba1   84        3
## DSP-1009880000092-G-A05 Full ROI 3144        4
## DSP-1009880000092-G-A08 Neuropil  631        5
## DSP-1009880000092-G-A06   Neuron 1414        6
plotSpatialOverlay(overlay = soObj, hiRes = FALSE, colorBy = "HPCA", scaleBar = FALSE) +
    viridis::scale_color_viridis() +
    ggplot2::labs(title = "HPCA Expression in Hippocampus")

3.5 Customizing the Figure

3.5.1 Add a scale bar

  • If scaleBar = TRUE, a scale bar is automatically calculated when plotting
  • Scale bars can be customized with the following parameters: scaleBarWidth, scaleBarColor, corner, etc.
plotSpatialOverlay(overlay = soObj, hiRes = FALSE, colorBy = "HPCA", scaleBarWidth = 0.3, scaleBarColor = "black", corner = "bottomleft") +
    viridis::scale_color_viridis()+
    ggplot2::labs(title = "HPCA Expression in Hippocampus")

3.5.2 Add the tissue image

  • Images can be added using readSpatialOverlay(image = TRUE) or added afterwards using the addImageOmeTiff function
  • Users can specify which resolution of the image to extrat with the res parameter
    • 1 = largest image and the higher values, i.e., 2, 3, …, 6, get smaller
  • Using a high resolution image, e.g., res=1, will cause a java memory error
soObj <- addImageOmeTiff(overlay = soObj, ometiff = tiffFile, res = 6)
plotSpatialOverlay(overlay = soObj, hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)

3.6 Image manipulation

3.6.1 Flipping X-axis

  • Reflect the image vertically
plotSpatialOverlay(overlay = flipX(soObj), hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)

3.6.2 Flipping Y-axis

  • Reflect the image horizontally
plotSpatialOverlay(overlay = flipY(soObj), hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)

3.6.3 Flipping X- and Y-aixs

  • Rotate the image 180 degrees
plotSpatialOverlay(overlay = flipY(flipX(soObj)), hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)

3.6.4 Crop tissue

  • The cropTissue function automatically detects where the tissue is and removes non-tissue area
  • The amount of area added to the cropped area can be defined by the buffer parameter
soObj <- cropTissue(overlay = soObj, buffer = 0.01)
plotSpatialOverlay(overlay = soObj, colorBy = "ROILabel", legend = FALSE, scaleBar = FALSE)

3.6.5 Crop sample

  • The cropSamples function automatically crops the image around the ROIs given
  • Users can feed in a subset of the samples with the sampleIDs parameter to zoom in
soObjSubset <- cropSamples(overlay = soObj, sampleIDs = lwAnnot$Sample_ID) # all samples in this tutorial

plotSpatialOverlay(overlay = soObjSubset, hiRes = FALSE, colorBy = "HPCA", scaleBar = FALSE) +
    viridis::scale_color_viridis()

3.7 Image (re)coloring

  • Fluorecence dye colors are determined from the instrument but can be recolored using the changeImageColoring function
  • Note that Target = Custom was set from Nanostring and the following information can be found in README_hu_brain.docx
Channel name Fluorescent dye Marker (Target) Cell/Structure marked
FITC/525 nm Alexa 488 GFAP Astrocytes
Cy3/568 nm SYTO 83 DNA Nuclei
Texas Red/615 nm Alexa 594 Iba1 Microglia
Cy5/666 nm Alexa 647 NeuN Neurons
fourCh <- add4ChannelImage(overlay = soObj)
fluor(fourCh)
##         Dye DisplayName  Color WaveLength Target ExposureTime MinIntensity
## 1 Alexa 488        FITC   Blue      525nm Custom     200.0 µs           42
## 2 Alexa 532         Cy3  Green      568nm    DNA      60.0 µs            9
## 3 Alexa 594   Texas Red Yellow      615nm Custom     250.0 µs           33
## 4 Alexa 647         Cy5    Red      666nm Custom     300.0 µs          225
##   MaxIntensity ColorCode
## 1        19257 #0000feff
## 2         8719 #00fe00ff
## 3        10392 #fefe00ff
## 4        30000 #fe0000ff
gp <- plotSpatialOverlay(overlay = soObj, hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)
legend <- fluorLegend(soObj, nrow = 2, textSize = 4, boxColor = "black", alpha = 0.8)
cowplot::ggdraw() +
    cowplot::draw_plot(gp) +
    cowplot::draw_plot(legend, scale = 0.2, x = -0.3, y = -0.3)

fourCh <- changeImageColoring(overlay = fourCh, color = "cyan", dye = "Alexa 488")
fourCh <- changeImageColoring(overlay = fourCh, color = "gold", dye = "Alexa 594")
fourCh <- changeImageColoring(overlay = fourCh, color = "magenta", dye = "Alexa 647")
fluor(fourCh)
##         Dye DisplayName   Color WaveLength Target ExposureTime MinIntensity
## 1 Alexa 488        FITC    Cyan      525nm Custom     200.0 µs           42
## 2 Alexa 532         Cy3   Green      568nm    DNA      60.0 µs            9
## 3 Alexa 594   Texas Red    Gold      615nm Custom     250.0 µs           33
## 4 Alexa 647         Cy5 Magenta      666nm Custom     300.0 µs          225
##   MaxIntensity ColorCode
## 1        19257      cyan
## 2         8719 #00fe00ff
## 3        10392      gold
## 4        30000   magenta
gp <- plotSpatialOverlay(overlay = fourCh, hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)
legend <- fluorLegend(fourCh, nrow = 2, textSize = 4, boxColor = "black", alpha = 0.8)
cowplot::ggdraw() +
    cowplot::draw_plot(gp) +
    cowplot::draw_plot(legend, scale = 0.2, x = -0.3, y = -0.3)