gplot: A function to create a grouped plot and return a table grob.

Description Usage Arguments Value Examples

View source: R/gplot.R

Description

This function allows you to create a grouped plot and return a table grob. It takes a tidy dataset containing sample replicate values for at least one variable, a column organizing each replicate into the proper comparison group, and a column that groups the variables to be plotted. Additional arguments allow for the re-ordering of the variables and the comparisons being ploted, selection of the type of graph to display (e.g., bar graph, boxplot, violin plot, points, statistical summary, etc...), as well as other aesthetics of the plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
gplot(dataset = NULL, comparison = NULL, group.by = NULL,
  levs = TRUE, val = "value", geom = c("bar", "errorbar", "point",
  "stat", "seg"), p = "p.signif", ref.group = NULL,
  p.adjust.method = "holm", comparisons = NULL, method = "t.test",
  paired = FALSE, errortype = "mean_sdl", y.lim = NULL,
  y.lab = NULL, trans.y = "identity", x.lim = c(NA, NA),
  expand.y = c(0, 0), x.lab = NULL, trans.x = "identity",
  sci = FALSE, angle.x = FALSE, levs.comps = TRUE,
  group.labs = NULL, stats = FALSE, split = TRUE, split_str = NULL,
  trim = "none", leg.pos = "top", stroke = 0.25, font_size = 9,
  size = 1, width = 0.8, dodge = 0.8, plotWidth = 30,
  plotHeight = 40, shape.groups = c(19, 21),
  color.groups = c("black", "black"), fill.groups = c("#444444", NA,
  "#A33838"))

Arguments

dataset

Define your data set which should be a gathered tibble

comparison

Specify the comparison you would like to make (e.g., Genotype)

group.by

Specify the variable to group by (e.g., Tissue).

levs

Specify the order of the grouping variables

val

Specify column name that contains values (optional)

geom

Define the list of geoms you want to plot

p

Specify representation of pvalue (p.signif = astrisk representation of the raw p value; p.format = 'p = 0.05'; p.adj = adjusted p-value; p.adj.signif = astrisk representation of the adjusted p value)

ref.group

Specify a reference group to compare all other comparisons to

p.adjust.method

Method used for adjusting the pvalue

comparisons

Specify which of the available comparisons within your data you would like to plot

method

Specify the statistical test to be used

paired

Specify whether or not the statistical comparisons should be paired

errortype

Specify the method of statistical error to plot

y.lim

Specify the min and max values to be used for the y-axis

y.lab

Specify a custom y-axis label to use

trans.y

Specify the transformation to perform on the dependent variable

x.lim

Specify the min and max values to be used for the x-axis

expand.y

Specify values to expand the y-axis

x.lab

Specify a custom x-axis label to use

trans.x

Specify the transformation to perform on the independent variable

sci

Specify whether or not to display the dependent variable using scientific notation

angle.x

Specify whether or not to angle the x-axis text 45deg

levs.comps

Specify the order in which to plot the comparisons

group.labs

Specify custom labels for the independent variables

stats

Specify whether or not to output the statistics table

split

Specify whether or not to split the x-axis label text

split_str

Specify the string to split the x-axis label text by; uses regex

trim

Specify the string to trim text from the right side of the x-axis label text; uses regex

leg.pos

Specify where to place the legend

stroke

Specify the line thickness to use

font_size

Specify the font size to use

size

Specify the size of the points to use

width

Specify the width of groups to be plotted

dodge

Specify the width to dodge the comparisons by

plotWidth

Specify the length of the x-axis in mm

plotHeight

Specify the length of the y-axis in mm

shape.groups

Specify the default shapes to use for the comparisons

color.groups

Specify the default colors to use for the comparisons

fill.groups

Specify the default fills to use for the comparisons

Value

Table grob of the plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
iris %>% dplyr::mutate(Species = as.character(Species)) %>%
dplyr::group_by(Species) %>%
dplyr::mutate(Sample = paste0(Species, "_", dplyr::row_number()),
Sheet = "iris") %>%
dplyr::select(Sample, Sheet, Species, dplyr::everything()) %>%
tidyr::gather(variable, value, -c(Sample, Sheet, Species)) %>%
dplyr::filter(variable == "Sepal.Length") %>%
plotGrouper::gplot(
comparison = "Species",
group.by = "variable",
shape.groups = c(19,21,17),
color.groups = c(rep("black",3)),
fill.groups = c("black","#E016BE", "#1243C9")) %>%
gridExtra::grid.arrange()

Example output

Warning messages:
1: `arrange_()` is deprecated as of dplyr 0.7.0.
Please use `arrange()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated. 
2: `select_()` is deprecated as of dplyr 0.7.0.
Please use `select()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated. 
3: `group_by_()` is deprecated as of dplyr 0.7.0.
Please use `group_by()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated. 
4: `fun.y` is deprecated. Use `fun` instead. 
5: `fun.ymin` is deprecated. Use `fun.min` instead. 
6: `fun.ymax` is deprecated. Use `fun.max` instead. 
7: `fun.y` is deprecated. Use `fun` instead. 
8: `fun.y` is deprecated. Use `fun` instead. 
9: `fun.y` is deprecated. Use `fun` instead. 

plotGrouper documentation built on Nov. 8, 2020, 5:25 p.m.