Save the figures

Please note:

Due to CRAN policies, this function could not make it to the official release and is only available in the development release of SCpubr. Find how to install it here.

Once the package becomes available on CRAN/Bioconductor, the function will be integrated in the official release.

Creating good plots is just half of the process. It is equally important to properly save them. This is the purpose of SCpubr::save_Plot. This function is a very handy tool to save your plots easily in different formats, such as .pdf, .png, .jpeg, .tiff and .svg. This can be achieved by providing the following to output_format parameter:

Width and Height are set by default to 8 inches each, so the plot is squared. However, it is really important that these parameters are modified to the user’s need. The name of the file can be provided with file_name parameter and the path to store the files can be specified in figure_path. If not provided, figure_path will default to the current working environment and file_name will default to a combination of the current date and time. Here are some examples.

# Generate a plot.
p <- SCpubr::do_DimPlot(sample = sample)

# Default parameters.
SCpubr::save_Plot(plot = p)

# Specifying the name and folder.
SCpubr::save_Plot(plot = p,
                 figure_path = "/path/to/my/figures/",
                 file_name = "my_figure")

# Specify to also create a new folder.
SCpubr::save_Plot(plot = p,
                 figure_path = "/path/to/my/figures/",
                 file_name = "my_figure",
                 create_path = TRUE)

# Set dimensions for the figure.
SCpubr::save_Plot(plot = p,
                 figure_path = "/path/to/my/figures/",
                 file_name = "my_figure",
                 create_path = TRUE,
                 width = 8,
                 height = 8)

# Set quality (dpi).
SCpubr::save_Plot(plot = p,
                 figure_path = "/path/to/my/figures/",
                 file_name = "my_figure",
                 create_path = TRUE,
                 width = 8,
                 height = 8,
                 dpi = 300)