This function saves a visualization object to a file in the specified
format and directory. It supports visualizations generated by
chea3_visualizeRank()
, ggplot2
, or any other plot object that
can be rendered using print()
inside a graphics device. Optionally,
the current date (stored in the today
variable) can be prepended to
the filename.
Usage
saveViz(
viz,
output_dir,
output_file = "figure_rChEA3",
format = "pdf",
with_date = TRUE,
width = 8,
height = 5,
resolution = 300,
verbose = TRUE
)
Arguments
- viz
A visualization object typically created by
visualizeRank()
, but can also be aggplot2
plot or any other plot object printable withprint()
.- output_dir
A string specifying the output directory. This parameter is required and has no default.
- output_file
A string specifying the base filename (without extension). Defaults to
"viz_rChEA3"
.- format
Output format. One of
"pdf"
,"png"
, or"svg"
. Defaults to"pdf"
.- with_date
Logical (default
TRUE
). Whether to prepend the current date (fromtoday
) to the filename.- width
Width of the output file in inches. Default is 8.
- height
Height of the output file in inches. Default is 5.
- resolution
Resolution in DPI (only used for PNG). Default is 300.
- verbose
Logical. If
TRUE
, print a message with the saved path. DefaultTRUE
.
Value
The visualization is saved to a file on disk. Invisibly returns the full path to the saved file.
Examples
# \donttest{
genes <- c("TP53", "MYC", "STAT3")
results <- queryChEA3(genes, verbose = FALSE)
meanRank_res <- results[["Integrated--meanRank"]]
# Create visualization
viz <- visualizeRank(meanRank_res)
# Save as PDF
saveViz(viz, output_dir = tempdir(), output_file = "chea3_results")
#> > Visualization (pdf) saved in /tmp/RtmpB0eR4n/20251010_chea3_results.pdf
# Save as PNG with custom dimensions
saveViz(viz, output_dir = tempdir(), output_file = "chea3_results",
format = "png", width = 10, height = 6)
#> > Visualization (png) saved in /tmp/RtmpB0eR4n/20251010_chea3_results.png
# }