genePlot | R Documentation |
Visualize gene expression data for exploratory data analysis
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,
...
)
x |
R data object; Most typically this is an |
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 |
symbol |
character; Column name of of gene symbols in the feature data of |
legend |
logical or character; Draws a figure legend. Use to set the legend title which defaults to "Legend" if equals |
main |
character; The main plot title. Defaults to true for automated generation. |
na.rm |
logical; Removes |
group |
factor or name of factor to be extracted from |
subgroup |
factor or name of factor to be extracted from |
highlight |
factor or name of factor to be extracted from |
facet |
factor or name of factor to be extracted from |
stack |
factor or name of factor to be extracted from |
shiny |
logical; Use |
groupByGene |
logical; If more then one gene is listed and |
useNormCounts |
logical; By default |
... |
Any parameter recognized by |
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.
an list of class npData
. This contains data necessary to regenerate the plot as well as summary statistics.
niceBox
, niceVio
, niceBar
, niceDots
, niceDensity
#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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.