plot_meta | R Documentation |
This is a meta function for plotting spatial heatmaps or co-visualizing bulk and single cell data that takes as input file paths of assay data and aSVG files.
plot_meta(
svg.path,
bulk,
cell = NULL,
match.lis = NULL,
assay.na = NULL,
sam.factor = NULL,
con.factor = NULL,
aggr = "mean",
ID,
var.cell = NULL,
dimred = "PCA",
cell.group = NULL,
tar.cell = NULL,
tar.bulk = NULL,
size.pt = 1,
alpha.pt = 0.8,
shape = NULL,
col.idp = FALSE,
decon = FALSE,
profile = TRUE,
charcoal = FALSE,
alpha.overlay = 1,
lay.shm = "gene",
ncol = 2,
h = 0.99,
size.r = 1,
col.com = c("yellow", "orange", "red"),
col.bar = "selected",
thr = c(NA, NA),
cores = NA,
bar.width = 0.08,
bar.title = NULL,
bar.title.size = 0,
scale = "no",
ft.trans = NULL,
tis.trans = ft.trans,
legend.r = 0,
lgd.plots.size = NULL,
sub.title.size = 11,
sub.title.vjust = 3,
legend.plot = "all",
ft.legend = "identical",
bar.value.size = 10,
legend.plot.title = "Legend",
legend.plot.title.size = 11,
legend.ncol = NULL,
legend.nrow = NULL,
legend.position = "bottom",
legend.direction = NULL,
legend.key.size = 0.02,
legend.text.size = 12,
angle.text.key = NULL,
position.text.key = NULL,
legend.2nd = FALSE,
position.2nd = "bottom",
legend.nrow.2nd = 2,
legend.ncol.2nd = NULL,
legend.key.size.2nd = 0.03,
legend.text.size.2nd = 10,
angle.text.key.2nd = 0,
position.text.key.2nd = "right",
dim.lgd.pos = "bottom",
dim.lgd.nrow = 2,
dim.lgd.key.size = 4,
dim.lgd.text.size = 13,
dim.axis.font.size = 8,
dim.capt.size = 13,
size.lab.pt = 5,
hjust.lab.pt = 0.5,
vjust.lab.pt = 1.5,
add.feature.2nd = FALSE,
label = FALSE,
label.size = 4,
label.angle = 0,
hjust = 0,
vjust = 0,
opacity = 1,
key = TRUE,
line.width = 0.2,
line.color = "grey70",
relative.scale = NULL,
out.dir = NULL,
animation.scale = 1,
selfcontained = FALSE,
aspr = 1,
video.dim = "640x480",
res = 500,
interval = 1,
framerate = 1,
bar.width.vdo = 0.1,
legend.value.vdo = NULL,
verbose = TRUE,
...
)
svg.path |
File paths of aSVG files. |
bulk , cell |
File paths of bulk and single cell data that are saved with saveRDS respectively. |
match.lis |
The file path of matching list that is saved with saveRDS. See |
assay.na |
The name of target assay to use when |
sam.factor |
The column name corresponding to spatial features in |
con.factor |
The column name corresponding to experimental variables in |
aggr |
Aggregate "sample__condition" replicates by "mean" or "median". The default is "mean". If the |
ID |
A character vector of assyed items (e.g. genes, proteins) whose abudance values are used to color the aSVG. |
var.cell |
The column name in the |
dimred |
One of |
cell.group |
Applicable when co-visualizing bulk and single-cell data with cell grouping methods of annodation labels, marker genes, clustering, or manual assignments. A column name in |
tar.cell |
Applicable when co-visualizing bulk and single-cell data with cell-to-bulk mapping. A vector of cell group labels in |
tar.bulk |
A vector of tissues of interest, which are mapped to single cells through cell group labels with |
size.pt , alpha.pt |
The size and alpha value of points in the embedding plot respectively. |
shape |
A named numeric vector of custom shapes for points in the embedding plot, where the names are the cluster labels and values are from |
col.idp |
Logical, if |
decon |
Logical, if |
profile |
Logical, applicable when co-visualizing bulk and single-cell data. If |
charcoal |
Logical, if |
alpha.overlay |
The opacity of the raster image under the SHM when superimposing raster images with SHMs. The default is 1. |
lay.shm |
One of 'gene', 'con', or 'none'. If 'gene', SHMs are organized horizontally by each biomolecule (gene, protein, or metabolite, etc.) and variables are sorted under each biomolecule. If 'con', SHMs are organized horizontally by each experiment vairable and biomolecules are sorted under each variable. If 'none', SHMs are organized by the biomolecule order in |
ncol |
The number of columns to display SHMs, which does not include the legend plot. |
h |
The height (0-1) of color key and SHM/co-visualization plots in the middle, not including legend plots. |
size.r |
The scaling ratio (0-1) of tissue section when visualizing the spatially resolved single-cell data. |
col.com |
A vector of color components used to build the color scale. The default is ‘c(’yellow', 'orange', 'red')'. |
col.bar |
One of 'selected' or 'all', the former uses expression values of |
thr |
A two-numeric vector of expression value thresholds (the range of the color bar). The first and the second element will be the minmun and maximum threshold in the color bar respectively. Values above the max or below min will be assigned the same color as the max or min respectively. The default is |
cores |
The number of CPU cores for parallelization. The default is 'NA', and the number of used cores is 1 or 2 depending on the availability. |
bar.width |
The width of color bar that ranges from 0 to 1. The default is 0.08. |
bar.title , bar.title.size |
The title and title size of the color key. |
scale |
One of |
ft.trans |
A character vector of spatial features that will be set transparent. When features of interest are covered by overlapping features on the top layers and the latter can be set transparent. |
tis.trans |
This argument is deprecated and replaced by |
legend.r |
A numeric (-1 to 1) to adjust the legend plot size. |
lgd.plots.size |
A vector of 2 or 3 numeric values that sum up between 0 and 1 (e.g., 'c(0.5, 0.4)'), corresponding to the sizes of legend plots in the co-visualization plot. If there are 2 values, the first and second values correspond to the sizes of the SHM and embedding plots, respectively. If there are 3 values, the first, second, and third values correspond to the sizes of the SHM, single-cell SHM, and embedding plots, respectively. |
sub.title.size |
A numeric of the subtitle font size of each individual spatial heatmap. The default is 11. |
sub.title.vjust |
A numeric of vertical adjustment for subtitle. The default is |
legend.plot |
A vector of suffix(es) of aSVG file name(s) such as |
ft.legend |
One of "identical", "all", or a character vector of tissue/spatial feature identifiers from the aSVG file. The default is "identical" and all the identical/matching tissues/spatial features between the data and aSVG file are colored in the legend plot. If "all", all tissues/spatial features in the aSVG are shown. If a vector, only the tissues/spatial features in the vector are shown. |
bar.value.size |
A numeric of value size in the y-axis of the color bar. The default is 10. |
legend.plot.title |
The title of the legend plot. The default is 'Legend'. |
legend.plot.title.size |
The title size of the legend plot. The default is 11. |
legend.ncol |
An integer of the total columns of keys in the legend plot. The default is NULL. If both |
legend.nrow |
An integer of the total rows of keys in the legend plot. The default is NULL. It is only applicable to the legend plot. If both |
legend.position |
the default position of legends ("none", "left", "right", "bottom", "top", "inside") |
legend.direction |
layout of items in legends ("horizontal" or "vertical") |
legend.key.size |
A numeric of the legend key size ("npc"), applicable to the legend plot. The default is 0.02. |
legend.text.size |
A numeric of the legend label size, applicable to the legend plot. The default is 12. |
angle.text.key |
Key text angle in legend plots. The default is NULL, equivalent to 0. |
position.text.key |
The position of key text in legend plots, one of 'top', 'right', 'bottom', 'left'. Default is NULL, equivalent to 'right'. |
legend.2nd |
Logical. If 'TRUE', the secondary legend is added to each SHM, which are the numeric values of each colored spatial features. The default its 'FALSE'. Only applies to the static image. |
position.2nd |
The position of the secondary legend in SHMs, one of 'top', 'right', 'bottom', 'left', or a two-component numeric vector. The default is 'bottom'. Applies to images and videos. |
legend.nrow.2nd |
An integer of rows of the secondary legend keys in SHMs. Applies to static images and videos. |
legend.ncol.2nd |
An integer of columns of the secondary legend keys in SHMs. Applies to static images and videos. |
legend.key.size.2nd |
A numeric of legend key size in SHMs. The default is 0.03. Applies to static images and videos. |
legend.text.size.2nd |
A numeric of the secondary legend text size in SHMs. The default is 10. Applies to static images and videos. |
angle.text.key.2nd |
Angle of the key text in the secondary legend in SHMs. Default is 0. Applies to static images and videos. |
position.text.key.2nd |
The position of key text in the secondary legend in SHMs, one of 'top', 'right', 'bottom', 'left'. Default is 'right'. Applies to static images and videos. |
dim.lgd.pos |
The position of legends in the embedding plot. One of |
dim.lgd.nrow |
The number of rows in the embedding plot legends. |
dim.lgd.key.size , dim.lgd.text.size |
The key and font size of the embedding plot legends respectively. |
dim.axis.font.size |
The size of axis font of the embedding plot. |
dim.capt.size |
The size of caption text in the dimension reduction plot in co-clustering (see |
size.lab.pt |
The size of point labels, applicable when |
hjust.lab.pt , vjust.lab.pt |
Numeric values to adjust the horizontal and vertical positions of point labels respectively, applicable when |
add.feature.2nd |
Logical. If 'TRUE', feature identifiers are added to the secondary legend. The default is FALSE. Applies to static images of SHMs. |
label |
Logical. If 'TRUE', the same spatial features between numeric data and aSVG are labeled by their identifiers. The default is 'FALSE'. It is useful when spatial features are labeled by similar colors. |
label.size |
The size of spatial feature labels in legend plots. The default is 4. |
label.angle |
The angle of spatial feature labels in legend plots. Default is 0. |
hjust , vjust |
The value to horizontally or vertically adjust positions of spatial feature labels in legend plots respectively. Default of both is 0. |
opacity |
The transparency of colored spatial features in legend plots. Default is 1. If 0, features are totally transparent. |
key |
Logical. If 'TRUE' (default), keys are added in legend plots. If |
line.width |
The thickness of each shape outline in the aSVG is maintained in spatial heatmaps, i.e. the stroke widths in Inkscape. This argument is the extra thickness added to all outlines. Default is 0.2 in case stroke widths in the aSVG are 0. |
line.color |
A character of the shape outline color. Default is "grey70". |
relative.scale |
A numeric to adjust the relative sizes between multiple aSVGs. Applicable only if multiple aSVGs are provided. Default is |
out.dir |
The directory to save SHMs as interactive HTML files and videos. Default is 'NULL', and the HTML files and videos are not saved. |
animation.scale |
A numeric to scale the SHM size in the HTML files. The default is 1, and the height is 550px and the width is calculated according to the original aspect ratio in the aSVG file. |
selfcontained |
Whether to save the HTML as a single self-contained file (with external resources base64 encoded) or a file with external resources placed in an adjacent directory. |
aspr |
The aspect ratio (width to height) in the interative HTML files. |
video.dim |
A single character of the dimension of video frame in form of 'widthxheight', such as '1920x1080', '1280x800', '320x568', '1280x1024', '1280x720', '320x480', '480x360', '600x600', '800x600', '640x480' (default). The aspect ratio of SHMs are decided by |
res |
Resolution of the video in dpi. |
interval |
The time interval (seconds) between SHM frames in the video. Default is 1. |
framerate |
An integer of video framerate in frames per seconds. Default is 1. Larger values make the video smoother. |
bar.width.vdo |
The color bar width (0-1) in videos. |
legend.value.vdo |
Logical. If 'TRUE', numeric values of colored spatial features are added to the video legend. The default is NULL. |
verbose |
Logical. If 'TRUE' (default), intermediate messages will be printed. |
... |
additional element specifications not part of base ggplot2. In general,
these should also be defined in the |
A 'SPHM' class.
Jianhai Zhang jzhan067@ucr.edu
Dr. Thomas Girke thomas.girke@ucr.edu
# Path of mouse brain aSVG.
svg.mus.brain.pa <- system.file("extdata/shinyApp/data", "mus_musculus.brain.svg", package="spatialHeatmap")
# Bulk data path.
blk.mus.pa <- system.file("extdata/shinyApp/data", "bulk_mouse_cocluster.rds", package="spatialHeatmap")
# Plotting spatial heatmaps.
plot_meta(svg.path=svg.mus.brain.pa, bulk=blk.mus.pa, sam.factor='tissue', aggr='mean', ID=c('AI593442', 'Adora1'), ncol=1, bar.width=0.1, legend.nrow=5, h=0.6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.