make_figure_title: Automatically generate acceptable figure and plot titles from...

View source: R/save_dye_screen_figs.R

make_figure_titleR Documentation

Automatically generate acceptable figure and plot titles from data

Description

A helper function of limited scope and flexibility. Given a dataframe, extracts values from specified columns and assembles them into titles and names. Exported only because it can be useful for general workflows as well. Generates experiment-specific names, of the format: Experiment_number (linebreak) Protein: protein name (linebreak) Buffer: buffer name Defaults to creating a title of the form: And a name of the form: <Experiment_number>protein_<protein_name>buffer_<buffer_name>

Usage

make_figure_title(
  df,
  .exp_num_col = "exp_num",
  .prot_name_col = "identity",
  .override_names = FALSE,
  .manual_exp_num = Sys.Date(),
  .manual_prot_name = "screened protein",
  .manual_buffer_name = "screening buffer",
  .type_col = "type",
  ...
)

Arguments

df

a df, e.g. one created by the tidy_dye_screen() function.

.exp_num_col

a string, giving the name of the column whose value will appear first in the titles/names. Defaults to "exp_num", which, if the dataframe comes from the tidy_dye_screen() function, contains the experiment number, e.g. "Exp1100". Ideally, this column would contain only one unique value. If more than one value is found, the first is used.

.prot_name_col

a string, giving the name of the column whose value will appear second in the titles/names. Defaults to "identity", which, if the dataframe comes from the tidy_dye_screen() function., contains the specific names of the protein and buffer corresponding to the experiment. This argument takes a dependence on the df also having a "type" column (the name of which can be supplied via .type_col), which can be used to filter to contain only the values "protein" or "buffer", to extract the name of the protein and the name of the buffer, as single unique strings, respectively.

.override_names

a boolean, which, if TRUE, overrides the names extracted from ..exp_num_col and .prot_name_col within the function, with the strings provided to the following arguments of this function. Defaults to FALSE.

.manual_exp_num

a string, which, if .override_names is set to TRUE, is used as the first element of both plot title and saved name.

.manual_prot_name

a string, which, if .override_names is set to TRUE, is used as the second element of both plot title and saved name, where the name of the protein typically appears.

.manual_buffer_name

a string, which, if .override_names is set to TRUE, is used as the third element of both plot title and saved name, where the name of the buffer typically appears.

.type_col

the name of the column which contains values of either "protein" or "buffer", which can be used to filter the input dataframe such that a single, unique name can be pulled from the .prot_name_col column for the protein (when filtered such that .type_col == "protein), or buffer (when filtered such that .type_col == "buffer").

...

tolerate unmatched arguments passed via .. from upstream functions; ignore if they don't match anything in this function

Value

a names list with two named elements: "print" – the name to be printed at the head of the plot, and "save" – the name to be used to save the plot via ggsave. Additional elements can be appended to the save name in the saving functions, to specify which figure is being saved when more than one figure is saved for the same experiment. Specific paths to save to are also set in the save_* plot functions of this package.


taiawu/dsfworld_package documentation built on June 18, 2024, 5:39 a.m.