expression_plot: Plots the expression profile of a gene by levels of a factor

Description Usage Arguments Value Warning Author(s) References See Also Examples

View source: R/post_analysis.R

Description

This function will plot the expression profile of a gene across a valid X-axis variable in the phenodata while representing the mean and confidence interval of groups of samples defined by levels of another valid grouping factor in the phenodata.

Usage

1
2
3
4
5
6
7
8
expression_plot(
    gene_id, result, eSet, x_var, f=result$factor, subset=NULL,
    xlab=x_var, ylab="log2(cpm)", ylim=range(exprs(eSet)),
    col.palette="Accent",
    col=brewer.pal(n=length(levels(pData(eSet)[,f])), name=col.palette),
    level=0.95, title=NULL, title.size=2, axis.title.size=20, 
    axis.text.size=15, axis.text.angle=0,
    legend.title.size=20, legend.text.size=15, legend.key.size=30)

Arguments

gene_id

An gene or probeset identifier present in rownames(expr_data).

result

An output of the GO_analyse() or subset_scores() function.

eSet

ExpressionSet of the Biobase package including a gene-by-sample expression matrix in the AssayData slot, and a phenotypic information data-frame in the phenodate slot. In the expression matrix, row names are Ensembl gene identifiers or probeset identifiers, and column names are sample identifiers. In the phentypic data-frame, row names are sample idenfifiers, column names are grouping factors and phenotypic traits usable for the one-way ANOVA.

x_var

A column name in phenodata to plot on the X-axis. If representing time on the X-axis, users should store the time-points as numeric values in the AnnotatedDataFrame to adequately space the time-points.

f

A column name in phenodata to group the samples when representing mean and confidence interval. The factor specified in the initial GO_analyse() call is used by default. Unexpected grouping factors of samples can reveal interesting trends (e.g. "Animal", "Tissue", "CellType", ...).

subset

A named list to subset eSet. Names must be column names existing in colnames(pData(eSet)). Values must be vectors of values existing in the corresponding column of pData(eSet).

xlab

Title of the X-axis. Default is tha value of x_var.

ylab

Title of the Y-axis. Default is "log2(cpm)".

ylim

Numeric vector of length 2 specifying the lower and upper bounds of the Y axis. Default is scaled to the full range of expression values in the expression dataset, to ease comparison of different genes. If set to NULL, the axis will be scaled to fit the plotted data only.

col.palette

A valid RColorBrewer palette name to fetch the colormap from. Default is palette "Accent".

col

A vector of color names or codes. The number of colors provided must match the number of levels of the grouping factor. If specified, overrides argument col.palette.

level

The confidence interval level to visualise around the mean of each group. Default is 0.95.

title

Changes the plot title. Default is a combination of the gene id and the associated gene.

title.size

Changes the font size of the title. Default is 2.

axis.title.size

Changes the font size of the axes title. Defalt is 20.

axis.text.size

Changes the font size of the axes text labels. Default is 15.

axis.text.angle

Changes the angle of the X axis text labels. Default is 0 (horizontal).

legend.title.size

Changes the font size of the legend title. Default is 20.

legend.text.size

Changes the font size of the legend text labels. Default is 15.

legend.key.size

Changes the size of the legend keys (in points). Default is 30.

Value

The ggplot object.

Warning

Common issues:

Author(s)

Kevin Rue-Albrecht

References

See Also

Package Biobase, methods expression_plot_symbol, GO_analyse and ggplot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# load the sample output data
data(AlvMac_results)

# Expression by gene identifier (TNIP3)
expression_plot(
    gene_id="ENSBTAG00000047107",
    result=AlvMac_results, eSet=AlvMac, x_var="Timepoint"
    )

# Same gene, plotted by animal and grouped by treatment (merging time points)
expression_plot(
    gene_id="ENSBTAG00000047107",
    result=AlvMac_results, eSet=AlvMac, x_var="Animal",
    f="Treatment")

# Same gene, plotted by animal and grouped by time-point (merging treatments)
expression_plot(
    gene_id="ENSBTAG00000047107",
    result=AlvMac_results, eSet=AlvMac, x_var="Animal",
    f="Time")

Example output

Loading required package: grid
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

    anyDuplicated, append, as.data.frame, basename, cbind, colnames,
    dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
    grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which.max, which.min

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

`geom_smooth()` using method = 'loess' and formula 'y ~ x'
There were 24 warnings (use warnings() to see them)
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
Warning message:
system call failed: Cannot allocate memory 

GOexpress documentation built on Nov. 8, 2020, 7:45 p.m.