GeoMx DSP Data
Visualization
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)
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
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")
Image
manipulation
Flipping
X-axis
- Reflect the image vertically
plotSpatialOverlay(overlay = flipX(soObj), hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)
Flipping
Y-axis
- Reflect the image horizontally
plotSpatialOverlay(overlay = flipY(soObj), hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)
Flipping X- and
Y-aixs
- Rotate the image 180 degrees
plotSpatialOverlay(overlay = flipY(flipX(soObj)), hiRes = FALSE, colorBy = "segment", scaleBar = FALSE)
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)
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()
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
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)