Saves a pheatmap derived RGenEDA heatmap object to a file in various
formats
including PNG, JPEG, TIFF, BMP, PDF, and SVG.
Arguments
- pheatmap_obj
A
pheatmapobject returned by an RGenEDA or pheatmap function.- filename
Character string specifying the path and filename where the heatmap should be saved.
- width
Numeric, the width of the output image. Default is 8.
- height
Numeric, the height of the output image. Default is 6.
- units
Character, units for width and height: one of "in", "cm", "mm", or "px". Default is "in". Values are converted to inches for PDF and SVG output.
- res
Numeric, the resolution (in dpi) for raster images. Default is 300.
- ...
Additional arguments passed to the graphics device function.
Details
This function is similar in spirit to ggsave() but works specifically
with pheatmap objects.
Examples
data(Snail1KO)
counts <- as.matrix(Snail1KO$rawCounts)
counts <- counts[rowSums(counts >= 10) >= 3, ]
meta <- Snail1KO$metadata
rownames(meta) <- meta$Sample
norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1)
obj <- GenEDA(normalized = norm, metadata = meta, counts = counts)
dists <- PlotDistances(obj, meta_cols = "Genotype")
out <- tempfile(fileext = ".png")
GenSave(dists, out, width = 6, height = 5)
file.exists(out)
#> [1] TRUE
