Plot and compare action potential parameters before and after a treatment
Source:R/Plot-data.R
plot_AP_comparison.Rd
Plot and compare action potential parameters before and after a treatment
Usage
plot_AP_comparison(
data,
plot_treatment = "Control",
plot_category = 2,
baseline_label = "Baseline",
post_hormone_label = "Post-hormone",
y_variable,
y_axis_title,
test_type,
treatment_colour_theme,
theme_options,
save_plot_png = "no",
ggplot_theme = patchclampplotteR_theme()
)
Arguments
- data
The action potential data generated from
add_new_cells()
withdata_type == "AP"
.- plot_treatment
A character value specifying the treatment you would like to plot (e.g. "Control").
plot_treatment
represents antagonists that were present on the brain slice, or the animals were fasted, etc.- plot_category
A numeric value specifying the category, which can be used to differentiate different protocol types. In the sample dataset for this package,
plot_category == 2
represents experiments where insulin was applied continuously after a 5-minute baseline period.- baseline_label
A character value for the x-axis label applied to the pre-hormone state. Defaults to "Baseline".
- post_hormone_label
A character value for x-axis label applied to the post-hormone or post-protocol state. Defaults to "Post-hormone" but you will likely change this to the hormone or protocol name.
- y_variable
A character value naming the variable to be plotted on the y-axis. Must be a column present in
data
. Examples includepeak_amplitude
,time_to_peak
,antipeak_amplitude
andhalf_width
.- y_axis_title
A character value used to define a "pretty" version of
y_variable
. This will become the y-axis label on the ggplot. Examples include "Peak Amplitude (pA)" or "Time to Peak (ms)".- test_type
A character (must be "wilcox.test", "t.test" or "none") describing the statistical model used to create a significance bracket comparing the pre- and post-hormone groups.
- treatment_colour_theme
A dataframe containing treatment names and their associated colours as hex values. See sample_treatment_names_and_colours for an example of what this dataframe should look like.
- theme_options
A dataframe containing theme options. See sample_theme_options for an example of what this dataframe should look like.
- save_plot_png
A character ("yes" or "no"). If "yes", the plot will be saved as a .png using ggsave. The filepath depends on the current type, but they will all go in subfolders below Figures/ in your project directory.
- ggplot_theme
The name of a ggplot theme or your custom theme. This will be added as a layer to a ggplot object. The default is
patchclampplotteR_theme()
, but other valid entries includetheme_bw()
,theme_classic()
or the name of a custom ggplot theme stored as an object.
Value
A ggplot object. If save_plot_png == "yes"
, it will also generate
a .png file in the folder Figures/Action-potentials
relative to the
project directory. The treatment and y_variable will be included in the filename.
Examples
plot_AP_comparison(
sample_AP_data,
plot_treatment = "Control",
plot_category = 2,
y_variable = "peak_amplitude",
y_axis_title = "Peak Amplitude (pA)",
theme_options = sample_theme_options,
baseline_label = "Baseline",
test_type = "wilcox.test",
post_hormone_label = "Insulin",
treatment_colour_theme = sample_treatment_names_and_colours,
save_plot_png = "no"
)