Save scatter plots of each feature against a set variable
Source:R/effect_plots.R
save_scatter_plots.Rd
Draws a scatterplots with a feature on y-axis and another variable on x-axis. A separate plot is drawn and saved for each feature.
Usage
save_scatter_plots(
object,
x = "Injection_order",
save = TRUE,
file_path = NULL,
format = "emf",
all_features = FALSE,
color = NULL,
color_scale = NA,
shape = NULL,
title = "Feature_ID",
subtitle = NULL,
shape_scale = getOption("notame.shape_scale"),
text_base_size = 14,
point_size = 2,
title_line_length = 40,
theme = theme_bw(base_size = text_base_size),
assay.type = NULL,
...
)
Arguments
- object
a
SummarizedExperiment
orMetaboSet
object- x
character, name of the column to be used as x-axis
- save
logical, if false, the plots are not saved but returned as a list
- file_path
character, a file path for PDF or prefix added to the file paths for other formats
- format
character, format in which the plots should be saved
- all_features
logical, should all features be used? If FALSE (the default), flagged features are removed before visualization.
- color
character, name of the column to be used for coloring
- color_scale
the color scale as returned by a ggplot function. Set to NA to choose the appropriate scale based on the class of the coloring variable.
- shape
character, name of the column used for shape
- title, subtitle
column names from feature data to use as plot title/filename and subtitle. Set to NULL for no title/subtitle, this creates running numbered filenames
- shape_scale
the shape scale as returned by a ggplot function
- text_base_size
integer, base size for text in figures
- point_size
numeric, size of the points
- title_line_length
integer, maximum length of the title line in characters, passed to
str_wrap
- theme
a ggplot theme to be added to the plot
- assay.type
character, assay to be used in case of multiple assays
- ...
other arguments to graphic device functions, like width and height
Value
By default, the function is invoked for its plot-saving side effect.
The function returns a list of plots when save = FALSE
.
Examples
data(example_set)
# Against injection order, colored by group
save_scatter_plots(
object = example_set[1:10],
x = "Injection_order",
color = "Group",
file_path = "./scatter_plots.pdf",
format = "pdf"
)
#> INFO [2025-06-23 22:38:29] Saved scatter plots to: ./scatter_plots.pdf
# Plot one feature
save_scatter_plots(example_set[1, ], save = FALSE)
#> Just a remainder, creating a long list of plots takes a lot of memory!
#> [[1]]
#>