plot_by_grp: Make box, dot, violin or bar plots for a feature per group

View source: R/plot_by_grp.R

plot_by_grpR Documentation

Make box, dot, violin or bar plots for a feature per group

Description

Make box, dot, violin or bar plotsfor a feature per group using ggplot2.

Usage

plot_by_grp(
  object,
  grp,
  name = "topgenes",
  width = 7,
  height = 7,
  main.v = "",
  xlab = "Group",
  ylab = "Log2 Expression",
  type = "dot",
  manual.color = NULL,
  x.angle = 0,
  add.se = FALSE,
  dotsize = 0.7,
  bins = 30,
  violin.alpha = 0.3,
  dot.alpha = 0.3,
  add.dot = FALSE,
  bar.width = 0.7,
  errorbar.width = 0.3
)

Arguments

object

Matrix-like object with features (e.g. genes) as rows and samples as columns.

grp

Vector of phenotype groups of the samples, which represent valid variable names in R. Should be same length as ncol(object). If the vector is named, names should match colnames(object).

name

Name of file to create. Set to NA to plot to screen instead of to file.

width

Manual option for determining the output file width in inches.

height

Manual option for determining the output file height in inches.

main.v

Character vector of main titles for plot.

xlab

Label for x-axis.

ylab

Label for y-axis.

type

Type of plot. Either "dot", "box", "violin", or "bar".

manual.color

Vector passed to both scale_fill_manual and scale_color_manual.

x.angle

Angle of x-axis text, passed to theme(axis.text.x=element_text(angle)).

add.se

Logical indicating if to add standard error of the mean to dot plot.

dotsize

Passed to geom_dotplot dotsize for dot plot.

bins

Used to calculate binwidth, which is passed to geom_dotplot binwidth for dot plot.

violin.alpha

Colour transparency in [0,1] for violin in violin plot.

dot.alpha

olour transparency in [0,1] for dots in violin plot.

add.dot

Logical indicating if to add individual data points as dots to bar plot.

bar.width

Width of the bars in bar plot.

errorbar.width

Width of the errorbars in bar plot.

Details

Based on type, "_dotplots", "_boxplots", "_violinplots", or "_barplots"is appended to name.

If object is a data frame, it is coerced to a matrix using data.matrix.

Value

Invisibly, a ggplot object from the last row of object that was plotted.


jdreyf/ezlimmaplot documentation built on Feb. 8, 2025, 2:25 a.m.