genePlot: Plot Gene Expression Data

View source: R/genePlot.R

genePlotR Documentation

Plot Gene Expression Data

Description

Visualize gene expression data for exploratory data analysis

Usage

genePlot(
  x,
  gene = NULL,
  plotType = c("box", "dot", "bar", "violin", "density", "surface"),
  theme = basicTheme,
  symbol = "GeneSymbol",
  legend = NULL,
  main = TRUE,
  na.rm = TRUE,
  group = NULL,
  subgroup = NULL,
  highlight = NULL,
  facet = NULL,
  stack = NULL,
  shiny = FALSE,
  groupByGene = TRUE,
  useNormCounts = TRUE,
  ...
)

Arguments

x

R data object; Most typically this is an ExpressionSet there is support for other data types as well.

gene

character; Gene or vector of gene names. These can either be rownames from the gene expression data or looked up in the feature data.

plotType

character; Can be set to "box", "violin, "dot", "bar", "density" or "surface" for boxplots, violin plots, dot plots, bar plots, and kernel density plots, respectively.

theme

npTheme object; A valid npTheme object the controls default settings. Defaults to basicTheme.

symbol

character; Column name of of gene symbols in the feature data of x (fData).

legend

logical or character; Draws a figure legend. Use to set the legend title which defaults to "Legend" if equals TRUE. Set to FALSE to disable.

main

character; The main plot title. Defaults to true for automated generation.

na.rm

logical; Removes NA values prior to ploting.

group

factor or name of factor to be extracted from x (e.g. pData). Used as the primary grouping factor.

subgroup

factor or name of factor to be extracted from x (e.g. pData). Used to subgroup data unless multiple genes are selected in which case subgroup is ignored.

highlight

factor or name of factor to be extracted from x (e.g. pData). Used to color data points by factor levels. Only valid for graphs with point overlays.

facet

factor or name of factor to be extracted from x (e.g. pData). Split the data into multiple smaller graphs.

stack

factor or name of factor to be extracted from x (e.g. pData). Used for stacked bar plots where both the individual and aggregate values are important. Valid only for bar plots.

shiny

logical; Use shiny interfaces if available.

groupByGene

logical; If more then one gene is listed and grouByGene is TRUE

useNormCounts

logical; By default genePlot will try to use normCounts() instead of counts() in SeqExpressionSets. Set to FALSE to use raw counts instead, though this will generate a warning about using non-normalized data.

...

Any parameter recognized by NicePlots functions. A complete list of these options can be found in bvt_graphic_options.

Details

The genePlot function is designed to make visualization of gene expression data simple and easy for R novices and bioinformaticians alike. The function is an S3 generic that accept various R and Bioconductor data sets as input and exacts the expression, factor and annotation data from them according to input data type. The factors allow for splitting expression data from one or more genes into groups and for various plot types with data point overlays where points can be colored by factors levels as well. If the input data is a Bioconductor data set such as an ExpressionSet and the gene option is used, genePlot will attempt to look up the genes in the associated feature annotation data (e.g. fData) according to the data input type and look for the gene symbol column indicated by the symbol option (defaults to 'GeneSymbol'). If no matches are found the row names of are checked of the expression data are check for matches as well. If character values are given for factor input, genePlot will attempt to look up associated phenotype data (e.g. pData). One can also pass raw data vectors/data frames and/or factors to genePlot to bypass this feature, which is critical for data sets and data formats where integrated phenotype and feature data is not available. The genePlot uses the NicePlots graphics library and any NicePlots option and/or theme can be used in conjunction with options detailed below. The plotType options supported correspond to NicePlots functions and include box plots (niceBox), dot plots (niceDots), violin plots (niceVio), bar plots (niceBar) as well as both one/two dimensional kernel density plots (niceDensity). Supported data input types include: ExpressionSet, SeqExpressionSet-class, SummarizedExperiment, EList-class, DESeqTransform, DiffBind dba objects, as well as standard R data types such as vector, matrix, data.frame, and tibble. genePlot silently returns a list of class npData that contains a summarized findings, p-values (if indicated), extracted plotting data, and plotting options. All npData objects can be replotted using the plot function, genePlot or any of the NicePlots functions. Options passed to any of these, including plotType will override the options for the npData object. For SummarizedExperiment and DiffBind dba objects, the assayType argument can be added to specify which assay to use if multiple options are available.

Value

an list of class npData. This contains data necessary to regenerate the plot as well as summary statistics.

See Also

niceBox, niceVio, niceBar, niceDots, niceDensity

Examples

#While designed for use with bioconductor datasets,
#genePlot can also be used for generic data like iris.

data(iris)

#Using a vector of data
genePlot(iris$Sepal.Length,gene=NA, highlight=iris$Species, plotType="dot", pointSize=.75,
width=.5, pointShape=1, main="Distribution of Sepal Length")

#Kernel density plots
genePlot(iris$Sepal.Length,gene=NA, group=iris$Species, plotType="density",
main="Distribution of Sepal Lengths by Species")

#Plotting multiple columns:
genePlot(t(iris[,1:4]),gene=c("Sepal.Length","Petal.Length"), plotType="violin",
highlight=iris$Species, pointShape=c(16:18), pointSize=.9, main="Violins with Point Highlights")

#Multiple columns with grouping factors:
genePlot(t(iris[,1:4]),gene=c("Sepal.Width","Petal.Width"), plotType="bar", group=iris$Species,
main="Multi-Column Data With Grouping Factor")

#Same with grouping order reversed
genePlot(t(iris[,1:4]),gene=c("Sepal.Width","Petal.Width"), plotType="bar", group=iris$Species,
groupByGene=FALSE, theme=npColorTheme, errFun="t95ci", legend=TRUE, main="Multi-Column Data With Grouping Factor")

#2D distribution plotting
genePlot(t(iris[,1:4]),gene=c("Sepal.Width","Petal.Width"), plotType="density",
group=iris$Species, theme=npGGTheme, main="2D Density Example")

#Surface plotting of the above. Use rgl for interactive models.
genePlot(t(iris[,1:4]),gene=c("Sepal.Width","Petal.Width"), plotType="surface", legend=TRUE,
useRgl=FALSE, theta=60, phi=30, theme=npGGTheme)


ZachHunter/bvt documentation built on Sept. 18, 2024, 3:12 p.m.