saveNetworkPlots {NAIR} | R Documentation |
Write Plots to a PDF
Description
Given a list of plots, write all plots to a single pdf file containing one plot per page, and optionally save the graph layout as a csv file.
Usage
saveNetworkPlots(
plotlist,
outfile,
pdf_width = 12,
pdf_height = 10,
outfile_layout = NULL,
verbose = FALSE
)
Arguments
plotlist |
A named list whose elements are of class |
outfile |
A |
pdf_width |
Sets the page width. Passed to the |
pdf_height |
Sets the page height. Passed to the |
outfile_layout |
An optional |
verbose |
Logical. If |
Value
Returns TRUE
, invisibly.
Author(s)
Brian Neal (Brian.Neal@ucsf.edu)
References
Hai Yang, Jason Cham, Brian Neal, Zenghua Fan, Tao He and Li Zhang. (2023). NAIR: Network Analysis of Immune Repertoire. Frontiers in Immunology, vol. 14. doi: 10.3389/fimmu.2023.1181825
Examples
set.seed(42)
toy_data <- simulateToyData()
net <-
generateNetworkObjects(
toy_data,
"CloneSeq"
)
net <-
addPlots(
net,
color_nodes_by =
c("SampleID", "CloneCount"),
print_plots = TRUE
)
saveNetworkPlots(
net$plots,
outfile =
file.path(tempdir(), "network.pdf"),
outfile_layout =
file.path(tempdir(), "graph_layout.txt")
)
# Load saved graph layout
graph_layout <- matrix(
scan(file.path(tempdir(), "graph_layout.txt"), quiet = TRUE),
ncol = 2
)
all.equal(graph_layout, net$plots$graph_layout)