diff_plot: Create difference plots

View source: R/diff_plot.R

diff_plotR Documentation

Create difference plots

Description

Create difference plots to show up- or down-regulation of certain lipids.

Usage

diff_plot(data, x, y, fill_by, facet_y, facet_x)

Arguments

data

data frame containing all information. See details for more information on the structure.

x

what to plot on the x-axis, often the variable e.g. lipid

y

what to plot on the y-axis, the difference

fill_by

column with factor for filling the bar plot

facet_y

facet in y direction with column

facet_x

facet in x direction with column

Details

data should be data frame which contains at least all the parameters as columns.

Value

A ggplot2 plot is returned.

Author(s)

Rico Derks

Examples

set.seed(123)

my_data <- data.frame(lipidname = c(paste("PA ", seq(30, 40, 2), ":0", sep = ""),
                                    paste("PA ", seq(30, 40, 2), ":1", sep = ""),
                                    paste("PA ", seq(30, 40, 2), ":2", sep = ""),
                                    paste("PC ", seq(30, 40, 2), ":0", sep = ""),
                                    paste("PC ", seq(30, 40, 2), ":1", sep = ""),
                                    paste("PC ", seq(30, 40, 2), ":2", sep = ""),
                                    paste("TG ", seq(50, 60, 1), ":0", sep = ""),
                                    paste("TG ", seq(50, 60, 1), ":1", sep = ""),
                                    paste("TG ", seq(50, 60, 1), ":2", sep = ""),
                                    paste("TG ", seq(50, 60, 1), ":3", sep = ""),
                                    paste("TG ", seq(50, 60, 1), ":4", sep = "")),
                      lipidclass = c(rep("PA", 18),
                                     rep("PC", 18),
                                     rep("TG", 55)),
                      difference = rnorm(n = 91, 
                                         mean = 0,
                                         sd = 3e4),
                      versus = factor(x = "AvsB"))

my_data$diff_grp <- as.factor(ifelse(my_data$difference > 0, "high", "low"))

diff_plot(data = my_data,
                x = lipidname,
                y = difference,
                fill_by = diff_grp,
                facet_x = versus,
                facet_y = lipidclass)


ricoderks/Rcpm documentation built on May 18, 2022, 7:49 a.m.