Title: | Spatial Overlay for Omic Data from Nanostring GeoMx Data |
---|---|
Description: | Tools for NanoString Technologies GeoMx Technology. Package to easily graph on top of an OME-TIFF image. Plotting annotations can range from tissue segment to gene expression. |
Authors: | Maddy Griswold [cre, aut], Megan Vandenberg [ctb], Stephanie Zimmerman [ctb] |
Maintainer: | Maddy Griswold <[email protected]> |
License: | MIT |
Version: | 1.7.0 |
Built: | 2024-11-02 02:52:00 UTC |
Source: | https://github.com/bioc/SpatialOmicsOverlay |
Add 4-channel image to SpatialOverlay from OME-TIFF. Allows for recoloring of image
add4ChannelImage(overlay, ometiff = NULL, res = NULL, ...)
add4ChannelImage(overlay, ometiff = NULL, res = NULL, ...)
overlay |
SpatialOverlay object |
ometiff |
File path to OME-TIFF. NULL indicates pull info from overlay |
res |
resolution layer, 1 = largest & higher values = smaller. The images increase in resolution and memory. The largest image your environment can hold is recommended. NULL indicates pull info from overlay |
... |
Extra variables |
SpatialOverlay object with image
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- add4ChannelImage(overlay = muBrain, ometiff = image, res = 8) dim(EBImage::imageData(showImage(muBrain)))
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- add4ChannelImage(overlay = muBrain, ometiff = image, res = 8) dim(EBImage::imageData(showImage(muBrain)))
Add image to SpatialOverlay from disk
addImageFile(overlay, imageFile = NULL, res = NULL)
addImageFile(overlay, imageFile = NULL, res = NULL)
overlay |
SpatialOverlay object |
imageFile |
path to image |
res |
what resolution is the image given? 1 = largest, higher number = smaller This value will affect the coordinates of the overlays. res = 2, resolution is 1/2 the size as the raw image res = 3, resolution is 1/4 the size as the raw image res = 4, resolution is 1/8 the size as the raw image resolution = 1/2^(res-1) |
SpatialOverlay object with image
Add image to SpatialOverlay from OME-TIFF
addImageOmeTiff(overlay, ometiff = NULL, res = NULL, ...)
addImageOmeTiff(overlay, ometiff = NULL, res = NULL, ...)
overlay |
SpatialOverlay object |
ometiff |
File path to OME-TIFF. NULL indicates pull info from overlay |
res |
resolution layer, 1 = largest & higher values = smaller. The images increase in resolution and memory. The largest image your environment can hold is recommended. NULL indicates pull info from overlay |
... |
Extra variables |
SpatialOverlay object with image
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) showImage(muBrain)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) showImage(muBrain)
SpatialOverlay
objectAdd plotting factor to SpatialOverlay
object
addPlottingFactor(overlay, annots, plottingFactor, ...) ## S4 method for signature 'NanoStringGeoMxSet' addPlottingFactor(overlay, annots, plottingFactor, countMatrix = "exprs") ## S4 method for signature 'matrix' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'tbl_df' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'tbl' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'data.frame' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'character' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'numeric' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'factor' addPlottingFactor(overlay, annots, plottingFactor)
addPlottingFactor(overlay, annots, plottingFactor, ...) ## S4 method for signature 'NanoStringGeoMxSet' addPlottingFactor(overlay, annots, plottingFactor, countMatrix = "exprs") ## S4 method for signature 'matrix' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'tbl_df' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'tbl' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'data.frame' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'character' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'numeric' addPlottingFactor(overlay, annots, plottingFactor) ## S4 method for signature 'factor' addPlottingFactor(overlay, annots, plottingFactor)
overlay |
|
annots |
factor vector with the plottingFactor. if names match sample names in overlay vector will be matched on those, otherwise assumed in the correct order |
plottingFactor |
name of the new plotting factor |
... |
if using |
countMatrix |
name of count matrix to pull counts from |
SpatialOverlay
object with new plotting factor
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)") muBrain <- addPlottingFactor(overlay = muBrain, annots = muBrainLW, plottingFactor = "segment") muBrainGxT <- readRDS(unzip(system.file("extdata", "muBrain_GxT.zip", package = "SpatialOmicsOverlay"))) muBrain <- addPlottingFactor(overlay = muBrain, annots = muBrainGxT, plottingFactor = "Calm1", countMatrix = "exprs") muBrain <- addPlottingFactor(overlay = muBrain, annots = seq_len(length(sampNames(muBrain))), plottingFactor = "ROINum") head(plotFactors(muBrain)) muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrain <- addPlottingFactor(overlay = muBrain, annots = as.factor(seq_len(length(sampNames(muBrain)))), plottingFactor = "ROINum") head(plotFactors(muBrain))
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)") muBrain <- addPlottingFactor(overlay = muBrain, annots = muBrainLW, plottingFactor = "segment") muBrainGxT <- readRDS(unzip(system.file("extdata", "muBrain_GxT.zip", package = "SpatialOmicsOverlay"))) muBrain <- addPlottingFactor(overlay = muBrain, annots = muBrainGxT, plottingFactor = "Calm1", countMatrix = "exprs") muBrain <- addPlottingFactor(overlay = muBrain, annots = seq_len(length(sampNames(muBrain))), plottingFactor = "ROINum") head(plotFactors(muBrain)) muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrain <- addPlottingFactor(overlay = muBrain, annots = as.factor(seq_len(length(sampNames(muBrain)))), plottingFactor = "ROINum") head(plotFactors(muBrain))
Match ROIs in annotation file to xml
annotMatching(annots, ROInum, maskNum, maskText, segCol = NULL)
annotMatching(annots, ROInum, maskNum, maskText, segCol = NULL)
annots |
df of annotations |
ROInum |
ROI number from xml file |
maskNum |
number of masks for ROI, used for AOI matching in software <= v2.4 |
maskText |
segment name, used for AOI matching in software v2.4+ |
segCol |
column containing segment name, if NULL function will determine automatically |
df with ROI unique identifiers
Print first and last n characters of string in this format: "### ... ### (x total char)"
bookendStr(x, bookend = 8)
bookendStr(x, bookend = 8)
x |
long string |
bookend |
number of characters on either side to print |
reformatted string
start_string <- stringi::stri_rand_strings(n = 1, length = 250) bookendStr(start_string, bookend = 6)
start_string <- stringi::stri_rand_strings(n = 1, length = 250) bookendStr(start_string, bookend = 6)
Update color intensities for changing to RGB image
changeColoringIntensity(overlay, minInten = NULL, maxInten = NULL, dye)
changeColoringIntensity(overlay, minInten = NULL, maxInten = NULL, dye)
overlay |
SpatialOverlay object |
minInten |
value to change MinIntensity to; NULL indicates no change |
maxInten |
value to change MaxIntensity to; NULL indicates no change |
dye |
which dye to change color, can be from Dye or DisplayName column from fluor(overlay) |
SpatialOverlay object with updated fluor data
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- add4ChannelImage(overlay = muBrain, ometiff = image, res = 8) fluor(muBrain) muBrain <- changeColoringIntensity(overlay = muBrain, minInten = 500, maxInten = 10000, dye = "Cy5") fluor(muBrain)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- add4ChannelImage(overlay = muBrain, ometiff = image, res = 8) fluor(muBrain) muBrain <- changeColoringIntensity(overlay = muBrain, minInten = 500, maxInten = 10000, dye = "Cy5") fluor(muBrain)
Update color scheme for changing to RGB image
changeImageColoring(overlay, color, dye)
changeImageColoring(overlay, color, dye)
overlay |
SpatialOverlay object, with 4channel image |
color |
color to change dye to, hex or color name |
dye |
which dye to change color, can be from Dye or DisplayName column from fluor(overlay) |
SpatialOverlay object with updated fluor data
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrain <- add4ChannelImage(overlay = muBrain, ometiff = downloadMouseBrainImage(), res = 8) fluor(muBrain) muBrain <- changeImageColoring(overlay = muBrain, color = "magenta", dye = "Cy5") muBrain <- changeImageColoring(overlay = muBrain, color = "#42f5ef", dye = "Alexa 488") fluor(muBrain)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrain <- add4ChannelImage(overlay = muBrain, ometiff = downloadMouseBrainImage(), res = 8) fluor(muBrain) muBrain <- changeImageColoring(overlay = muBrain, color = "magenta", dye = "Cy5") muBrain <- changeImageColoring(overlay = muBrain, color = "#42f5ef", dye = "Alexa 488") fluor(muBrain)
Determine lowest resolution image in OME-TIFF
checkValidRes(ometiff)
checkValidRes(ometiff)
ometiff |
path to OME-TIFF |
value of lowest res image
image <- downloadMouseBrainImage() checkValidRes(ometiff = image)
image <- downloadMouseBrainImage() checkValidRes(ometiff = image)
Create coordinate file for entire scan
createCoordFile(overlay, outline = TRUE)
createCoordFile(overlay, outline = TRUE)
overlay |
SpatialOverlay object |
outline |
returned coordinates only contain boundaries, will not work for segmented ROIs |
df of coordinates for every AOI in the scan
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrain <- createCoordFile(muBrain, outline = FALSE) head(coords(muBrain))
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrain <- createCoordFile(muBrain, outline = FALSE) head(coords(muBrain))
Create a binary mask from a base 64 string
createMask(b64string, metadata, outline = TRUE)
createMask(b64string, metadata, outline = TRUE)
b64string |
base 64 string |
metadata |
metadata of AOI including: Height, Width of AOI |
outline |
only the outline points should be returned |
binary mask image
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) samp <- which(sampNames(muBrain) == "DSP-1012999073013-A-F12") ROIMask <- createMask(b64string = position(overlay(muBrain))[samp], metadata = meta(overlay(muBrain))[samp,], outline = TRUE) pheatmap::pheatmap(ROIMask, cluster_rows = FALSE, cluster_cols = FALSE)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) samp <- which(sampNames(muBrain) == "DSP-1012999073013-A-F12") ROIMask <- createMask(b64string = position(overlay(muBrain))[samp], metadata = meta(overlay(muBrain))[samp,], outline = TRUE) pheatmap::pheatmap(ROIMask, cluster_rows = FALSE, cluster_cols = FALSE)
Crop to zoom in on given ROIs
cropSamples(overlay, sampleIDs, buffer = 0.1, sampsOnly = TRUE)
cropSamples(overlay, sampleIDs, buffer = 0.1, sampsOnly = TRUE)
overlay |
SpatialOverlay object |
sampleIDs |
sampleIDs of ROIs to keep in image |
buffer |
percent of new image size to add to each edge as a buffer |
sampsOnly |
should only ROIs with given sampleIDs be in image |
SpatialOverlay object
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) samps <- sampNames(muBrain) muBrainCrop <- suppressWarnings(cropSamples(overlay = muBrain, sampleIDs = samps, sampsOnly = TRUE)) plotSpatialOverlay(overlay = muBrainCrop, scaleBar = FALSE, hiRes = TRUE, legend = FALSE)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) samps <- sampNames(muBrain) muBrainCrop <- suppressWarnings(cropSamples(overlay = muBrain, sampleIDs = samps, sampsOnly = TRUE)) plotSpatialOverlay(overlay = muBrainCrop, scaleBar = FALSE, hiRes = TRUE, legend = FALSE)
Crop to remove black boundary around tissue.
cropTissue(overlay, buffer = 0.05)
cropTissue(overlay, buffer = 0.05)
overlay |
SpatialOverlay object |
buffer |
percent of new image size to add to each edge as a buffer |
SpatialOverlay object
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) muBrainCrop <- cropTissue(overlay = muBrain) plotSpatialOverlay(overlay = muBrainCrop, legend = FALSE, hiRes = FALSE, scaleBar = FALSE)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) muBrainCrop <- cropTissue(overlay = muBrain) plotSpatialOverlay(overlay = muBrainCrop, legend = FALSE, hiRes = FALSE, scaleBar = FALSE)
Download Mouse Brain OME-TIFF from NanoString's Spatial Organ Atlas
downloadMouseBrainImage()
downloadMouseBrainImage()
https://nanostring.com/products/geomx-digital-spatial-profiler/spatial-organ-atlas/mouse-brain/
mouse brain OME-TIFF
image <- downloadMouseBrainImage()
image <- downloadMouseBrainImage()
Flip x axis in image and overlay points
flipX(overlay)
flipX(overlay)
overlay |
SpatialOverlay object |
SpatialOverlay object with x axis flipped
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) showImage(flipX(muBrain))
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) showImage(flipX(muBrain))
Flip y axis in image and overlay points
flipY(overlay)
flipY(overlay)
overlay |
SpatialOverlay object |
SpatialOverlay object with y axis flipped
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) showImage(flipY(muBrain))
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- addImageOmeTiff(overlay = muBrain, ometiff = image, res = 8) showImage(flipY(muBrain))
Creates legend that can be overlayed on image using cowplot
.
fluorLegend(overlay, nrow = 4, textSize = 10, boxColor = "grey", alpha = 0.25)
fluorLegend(overlay, nrow = 4, textSize = 10, boxColor = "grey", alpha = 0.25)
overlay |
SpatialOverlay |
nrow |
number of rows in the legend. Most studies have 4 which is where the values came from: 1 = horizontal legend, 4 = vertical legend, 2 = box legend |
textSize |
font size |
boxColor |
color of box behind legend |
alpha |
alpha value of box behind legend |
gp of fluorescence legend
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) # image <- downloadMouseBrainImage() # muBrain <- addImageOmeTiff(overlay = muBrain, # ometiff = image, res = 8) gp <- plotSpatialOverlay(overlay = muBrain, hiRes = FALSE, scaleBar = FALSE) legend <- fluorLegend(muBrain, nrow = 2, textSize = 3, boxColor = "red") cowplot::ggdraw() + cowplot::draw_plot(gp) + cowplot::draw_plot(legend, scale = 0.12, x = -0.3, y = -0.25)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) # image <- downloadMouseBrainImage() # muBrain <- addImageOmeTiff(overlay = muBrain, # ometiff = image, res = 8) gp <- plotSpatialOverlay(overlay = muBrain, hiRes = FALSE, scaleBar = FALSE) legend <- fluorLegend(muBrain, nrow = 2, textSize = 3, boxColor = "red") cowplot::ggdraw() + cowplot::draw_plot(gp) + cowplot::draw_plot(legend, scale = 0.12, x = -0.3, y = -0.25)
If generated coordinates do not match the image use this function to move coordinates. Coordinates are only changed 1 pixel at a time.
moveCoords(overlay, direction = "right")
moveCoords(overlay, direction = "right")
overlay |
SpatialOverlay object |
direction |
which direction should coordinates move: left, right, up, down |
SpatialOverlay object
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) head(coords(muBrain), 3) head(coords(moveCoords(muBrain, direction = "up")), 3)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) head(coords(muBrain), 3) head(coords(moveCoords(muBrain, direction = "up")), 3)
Parse the xml file for AOI attributes in GeoMx images
parseOverlayAttrs(omexml, annots, labworksheet, ...)
parseOverlayAttrs(omexml, annots, labworksheet, ...)
omexml |
xml file from OME-TIFF, can provide path to OME-TIFF and xml will automatically be extracted |
annots |
df of annotations |
labworksheet |
annots are from lab worksheet file |
... |
segCol in annotMatching, if auto detection doesn't work. |
SpatialPosition of AOIs containing metadata and base64encoded positions
image <- downloadMouseBrainImage() xml <- xmlExtraction(ometiff = image) muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)") overlay <- parseOverlayAttrs(omexml = xml, annots = muBrainLW, labworksheet = TRUE)
image <- downloadMouseBrainImage() xml <- xmlExtraction(ometiff = image) muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)") overlay <- parseOverlayAttrs(omexml = xml, annots = muBrainLW, labworksheet = TRUE)
Parse the xml file for the scan metadata of GeoMx images
parseScanMetadata(omexml)
parseScanMetadata(omexml)
omexml |
xml file from OME-TIFF, can provide path to OME-TIFF and xml will automatically be extracted |
metadata for entire scan
image <- downloadMouseBrainImage() xml <- xmlExtraction(ometiff = image) scan_metadata <- parseScanMetadata(omexml = xml)
image <- downloadMouseBrainImage() xml <- xmlExtraction(ometiff = image) scan_metadata <- parseScanMetadata(omexml = xml)
overlay plots
plotSpatialOverlay( overlay, colorBy = "sampleID", hiRes = TRUE, alpha = 1, legend = TRUE, scaleBar = TRUE, image = TRUE, fluorLegend = FALSE, ..., corner = "bottomright", scaleBarWidth = 0.2, scaleBarMicrons = NULL, scaleBarColor = NULL, scaleBarFontSize = 6, scaleBarLineSize = 1.5, textDistance = 2 )
plotSpatialOverlay( overlay, colorBy = "sampleID", hiRes = TRUE, alpha = 1, legend = TRUE, scaleBar = TRUE, image = TRUE, fluorLegend = FALSE, ..., corner = "bottomright", scaleBarWidth = 0.2, scaleBarMicrons = NULL, scaleBarColor = NULL, scaleBarFontSize = 6, scaleBarLineSize = 1.5, textDistance = 2 )
overlay |
SpatialOverlay object |
colorBy |
annotation to color by |
hiRes |
generated figures are either high resolution or print quickly. Note: hiRes and outline ggplots use fill, lowRes uses color |
alpha |
opacity of overlays |
legend |
should legend be plotted |
scaleBar |
should scale bar be plotted |
image |
should image be plotted, image must be added to SpatialOverlay object |
fluorLegend |
should viz marker on the image be added to legend |
... |
additional parameters for scale bar line & text, will affect both |
corner |
where in the figure should the scale bar be printed. Options: "bottomright" "topright" "bottomleft" "topleft" "bottomcenter" "topcenter" |
scaleBarWidth |
percent of total figure the scale bar should take up |
scaleBarMicrons |
specific microns to set scale bar at, overrides scaleBarWidth if set |
scaleBarColor |
scale bar & text color |
scaleBarFontSize |
font size |
scaleBarLineSize |
width of line |
textDistance |
text's distance from scale bar. |
gp
hiRes and outline ggplots use fill, lowRes uses color
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) plotSpatialOverlay(overlay = muBrain, legend = FALSE, hiRes = FALSE, scaleBar = FALSE)
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) plotSpatialOverlay(overlay = muBrain, legend = FALSE, hiRes = FALSE, scaleBar = FALSE)
Read lab worksheet into dataframe of annotations
readLabWorksheet(lw, slideName, roiCol = NULL, slideCol = NULL)
readLabWorksheet(lw, slideName, roiCol = NULL, slideCol = NULL)
lw |
lab worksheet file path |
slideName |
name of slide |
roiCol |
column containing ROI information, if NULL function will determine automatically |
slideCol |
column containing slide name, if NULL function will determine automatically |
df of ROI annotations
muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)")
muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)")
SpatialOverlay
from tiff file and annotationsCreate an instance of class SpatialOverlay
by reading data from OME-TIFF and annotation sheet.
readSpatialOverlay( ometiff, annots, slideName, image = FALSE, res = NULL, saveFile = FALSE, outline = TRUE, ..., segCol = NULL )
readSpatialOverlay( ometiff, annots, slideName, image = FALSE, res = NULL, saveFile = FALSE, outline = TRUE, ..., segCol = NULL )
ometiff |
path to OME-TIFF |
annots |
path to annotation file: can be labWorksheet, DA excel file, or delimted file |
slideName |
name of slide |
image |
should image be extracted from OME-TIFF |
res |
resolution of image 1 = largest, higher number = smaller This value will affect the coordinates of the overlays. res = 2, resolution is 1/2 the size as the raw image res = 3, resolution is 1/4 the size as the raw image res = 4, resolution is 1/8 the size as the raw image resolution = 1/2^(res-1) |
saveFile |
should xml & image be saved, file is saved in working directory with same name as OME-TIFF |
outline |
returned coordinates only contain outlinearies, will not work for segmented ROIs |
... |
additional parameters for 'readLabWorksheet' like 'roiCol' and 'slideCol' |
segCol |
additional parameter for ‘annotMatching' if default search doesn’t work. For default search, set to NULL |
SpatialOverlay
of slide
muBrain_GxT <- readRDS(unzip(system.file("extdata", "muBrain_GxT.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- readSpatialOverlay(ometiff = image, annots = muBrain_GxT[,1:5], slideName = "D5761 (3)", image = TRUE, res = 8, saveFile = FALSE, outline = FALSE)
muBrain_GxT <- readRDS(unzip(system.file("extdata", "muBrain_GxT.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- readSpatialOverlay(ometiff = image, annots = muBrain_GxT[,1:5], slideName = "D5761 (3)", image = TRUE, res = 8, saveFile = FALSE, outline = FALSE)
recolor images after changing colors and/or color intensities
recolor(overlay)
recolor(overlay)
overlay |
SpatialOverlay object |
SpatialOverlay object with RGB image
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- add4ChannelImage(overlay = muBrain, ometiff = image, res = 8) muBrain <- changeImageColoring(overlay = muBrain, color = "magenta", dye = "Cy5") showImage(recolor(muBrain))
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) image <- downloadMouseBrainImage() muBrain <- add4ChannelImage(overlay = muBrain, ometiff = image, res = 8) muBrain <- changeImageColoring(overlay = muBrain, color = "magenta", dye = "Cy5") showImage(recolor(muBrain))
Remove sample(s) from SpatialOverlay
removeSample(overlay, remove)
removeSample(overlay, remove)
overlay |
SpatialOverlay object |
remove |
sampNames of overlay to remove |
SpatialOverlay object without samples in remove
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)") samps <- muBrainLW$Sample_ID[muBrainLW$segment != "Full ROI"] muBrainSub <- removeSample(overlay = muBrain, remove = samps) muBrain muBrainSub
muBrain <- readRDS(unzip(system.file("extdata", "muBrainSubset_SpatialOverlay.zip", package = "SpatialOmicsOverlay"))) muBrainLW <- system.file("extdata", "muBrain_LabWorksheet.txt", package = "SpatialOmicsOverlay") muBrainLW <- readLabWorksheet(muBrainLW, slideName = "D5761 (3)") samps <- muBrainLW$Sample_ID[muBrainLW$segment != "Full ROI"] muBrainSub <- removeSample(overlay = muBrain, remove = samps) muBrain muBrainSub
The SpatialOverlay
class organizes the pertinant information from the
OME-TIFFs allowing for plotting on top of or beside the image
SpatialOverlay(slideName, scanMetadata, overlayData, coords = NULL, plottingFactors = NULL, workflow = list(outline=FALSE, labWorksheet=TRUE, scaled=FALSE), image = list(filePath = NULL, imagePointer = NULL, resolution = NULL))
SpatialOverlay(slideName, scanMetadata, overlayData, coords = NULL, plottingFactors = NULL, workflow = list(outline=FALSE, labWorksheet=TRUE, scaled=FALSE), image = list(filePath = NULL, imagePointer = NULL, resolution = NULL))
slideName |
The name of the slide in the |
scanMetadata |
A |
overlayData |
An |
coords |
An optional |
plottingFactors |
An optional |
workflow |
A |
image |
A |
An S4 class containing image data from a NanoString GeoMx experiment
SpatialOverlay
objects have the following accessor methods:
extracts the sample names of each ROI in the slide.
extracts the slide name.
extracts the SpatialPosition
information for each ROI.
extracts the scan metadata.
coords(object)
: extracts the coordinates for the entire scan.
extracts avaliable plotting factors.
extracts the boolean if a lab worksheet was used.
extracts the boolena if only the outline points were generated.
extracts if there are any segmented ROIs in the slide.
extracts the scale bar ratio from scanMeta
for the X axis
extracts fluorenscence information for the scan.
prints image.
extracts resolution of image.
extracts workflow data.
extracts if coordinates have been scaled.
extracts image data.
The SpatialPosition
class organizes the pertinant ROI specific information
from the OME-TIFFs
SpatialPosition(position)
SpatialPosition(position)
position |
|
An S4 class containing image data from a NanoString GeoMx experiment
SpatialPosition
objects have the following accessor methods:
returns SpatialPosition object
extracts the metadata for each ROI, does not include the base64 encoding.
extracts the base64 encoding for each ROI, CAUTION: very long strings.
Extract xml from OME-TIFF
xmlExtraction(ometiff, saveFile = FALSE, outdir = NULL)
xmlExtraction(ometiff, saveFile = FALSE, outdir = NULL)
ometiff |
path to OME-TIFF |
saveFile |
should xml be saved, file is saved in working directory with same name as OME-TIFF |
outdir |
output directory for saved xml. If NULL, saved in same directory as OME-TIFF |
list of xml data
image <- downloadMouseBrainImage() xml <- xmlExtraction(ometiff = image)
image <- downloadMouseBrainImage() xml <- xmlExtraction(ometiff = image)