read_svg: Parsing annotated SVG (aSVG) files

View source: R/read_svg.R

read_svgR Documentation

Parsing annotated SVG (aSVG) files

Description

Parse one or multiple aSVG files and store their coordinates and related attributes in an SVG container, which will be used for creating spatial heatmap (SHM) plots.

Usage

read_svg(svg.path, raster.path = NULL, cores = 1, srsc = FALSE)

Arguments

svg.path

A vector of one or multiple paths of aSVG files. If multiple aSVGs, such as aSVGs depicting organs development across mutiple times, the aSVGs should be indexed with suffixes "_shm1", "_shm2", ..., such as "arabidopsis.thaliana_organ_shm1.svg", "arabidopsis.thaliana_organ_shm2.svg".

raster.path
  • A vector of one or multiple paths of raster images in form of jpg or png, which are usually used as templates for creating aSVG images in svg.path. Optional (default is NULL), only applicable when superimposing raster images with SHM plots that are created from aSVG images.

  • Matching raster and aSVG images is indicated by identical base names such as imageA.png and imageA.svg. The layout order in SHMs composed of multiple independent images is controlled by numbering the corresponding file pairs accordingly such as imageA_1.png and imageA_1.svg, imageB_2.png and imageB_2.svg, etc.

cores

Number of CPUs to parse the aSVG files (default is 1).

srsc

Logical. If 'TRUE', the aSVG is considered for co-visualizing spatially resolved single-cell and bulk data, and the rotation angle of the tissue section for spatial assays will be recorded.

Value

An object of SVG class, containing one or multiple aSVG instances.

Author(s)

Jianhai Zhang jzhan067@ucr.edu
Dr. Thomas Girke thomas.girke@ucr.edu

References

Hadley Wickham, Jim Hester and Jeroen Ooms (2019). xml2: Parse XML. R package version 1.2.2. https://CRAN.R-project.org/package=xml2

See Also

SVG: the SVG class.

Examples


# The first raste image used as a template to create an aSVG. 
raster.pa1 <- system.file('extdata/shinyApp/data/maize_leaf_shm1.png',
package='spatialHeatmap')
# The first aSVG created with the first template. 
svg.pa1 <- system.file('extdata/shinyApp/data/maize_leaf_shm1.svg',
package='spatialHeatmap')
# The second raster image used as a template to create an aSVG. 
raster.pa2 <- system.file('extdata/shinyApp/data/maize_leaf_shm2.png',
package='spatialHeatmap')
# The second aSVG created with the second template. 
svg.pa2 <- system.file('extdata/shinyApp/data/maize_leaf_shm2.svg',
package='spatialHeatmap')

# Parse these two aSVGs without association with raster images.
svgs <- read_svg(svg.path=c(svg.pa1, svg.pa2), raster.path=NULL)
# Parse these two aSVGs. The raster image paths are provide so as to
# be associated with respective aSVGs, which will be used when 
# superimposing raster images with SHM plots.
svgs <- read_svg(svg.path=c(svg.pa1, svg.pa2), raster.path=c(raster.pa1, raster.pa2))

jianhaizhang/spatialHeatmap documentation built on April 21, 2024, 7:43 a.m.