Last data update: 2014.03.03

R: Plot expression values for a set of features (e.g. genes or...
plotExpressionR Documentation

Plot expression values for a set of features (e.g. genes or transcripts)

Description

Plot expression values for a set of features (e.g. genes or transcripts)

Usage

plotExpression(object, ...)

plotExpressionSCESet(object, features, x, exprs_values = "exprs",
  colour_by = NULL, shape_by = NULL, size_by = NULL, ncol = 2,
  xlab = NULL, show_median = FALSE, show_violin = TRUE,
  show_smooth = FALSE, theme_size = 10, log2_values = FALSE)

plotExpressionDefault(object, aesth, ncol = 2, xlab = NULL, ylab = NULL,
  show_median = FALSE, show_violin = TRUE, show_smooth = FALSE)

## S4 method for signature 'SCESet'
plotExpression(object, ...)

## S4 method for signature 'data.frame'
plotExpression(object, ...)

Arguments

object

an SCESet object containing expression values and experimental information. Must have been appropriately prepared. For the plotExpressionDefault method, the object argument is a data.frame in 'long' format providing expression values for a set of features to plot, plus metadata used in the aesth argument, but this is not meant to be a user-level operation.

...

optional arguments (from those listed above) passed to plotExpressionSCESet or plotExpressionDefault

features

a character vector of feature names or Boolean vector or numeric vector of indices indicating which features should have their expression values plotted

x

character string providing a column name of pData(object) or a feature name (i.e. gene or transcript) to plot on the x-axis in the expression plot(s). If a feature name, then expression values for the feature will be plotted on the x-axis for each subplot.

exprs_values

character string indicating which values should be used as the expression values for this plot. Valid arguments are "tpm" (default; transcripts per million), "norm_tpm" (normalised TPM values), "fpkm" (FPKM values), "norm_fpkm" (normalised FPKM values), "counts" (counts for each feature), "norm_counts", "cpm" (counts-per-million), "norm_cpm" (normalised counts-per-million), "exprs" (whatever is in the 'exprs' slot of the SCESet object; default), "norm_exprs" (normalised expression values) or "stand_exprs" (standardised expression values) or any other slots that have been added to the "assayData" slot by the user.

colour_by

optional character string supplying name of a column of pData(object) which will be used as a variable by which to colour expression values on the plot.

shape_by

optional character string supplying name of a column of pData(object) which will be used as a variable to define the shape of points for expression values on the plot.

size_by

optional character string supplying name of a column of pData(object) which will be used as a variable to define the size of points for expression values on the plot.

ncol

number of columns to be used for the panels of the plot

xlab

label for x-axis; if NULL (default), then x will be used as the x-axis label

show_median

logical, show the median for each group on the plot

show_violin

logical, show a violin plot for the distribution for each group on the plot

show_smooth

show a smoothed fit through the data points?

theme_size

numeric scalar giving default font size for plotting theme (default is 10)

log2_values

should the expression values be transformed to the log2-scale for plotting (with an offset of 1 to avoid logging zeroes)?

aesth

an aes object to use in the call to ggplot.

ylab

character string defining a label for the y-axis (y-axes) of the plot.

Details

Plot expression values (default log2(transcripts-per-million + 1), if available) for a set of features.

Value

a ggplot plot object

Examples

## prepare data
data("sc_example_counts")
data("sc_example_cell_info")
pd <- new("AnnotatedDataFrame", data = sc_example_cell_info)
example_sceset <- newSCESet(countData = sc_example_counts, phenoData = pd)
example_sceset <- calculateQCMetrics(example_sceset)

## default plot
plotExpression(example_sceset, 1:6, "Mutation_Status")

## explore options
plotExpression(example_sceset, 1:6, x="Mutation_Status", exprs_values="exprs",
colour_by="Cell_Cycle", show_violin=TRUE, show_median=TRUE)
plotExpression(example_sceset, 1:6, x="Mutation_Status", exprs_values="counts",
colour_by="Cell_Cycle", show_violin=TRUE, show_median=TRUE)

## plot expression against expression values for Gene_0004
plotExpression(example_sceset, 1:4, "Gene_0004")
plotExpression(example_sceset, 1:4, "Gene_0004", show_smooth = TRUE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(scater)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

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

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

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

Welcome to Bioconductor

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

Loading required package: ggplot2

Attaching package: 'scater'

The following object is masked from 'package:stats':

    filter

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/scater/plotExpression.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotExpression
> ### Title: Plot expression values for a set of features (e.g. genes or
> ###   transcripts)
> ### Aliases: plotExpression plotExpression,SCESet-method
> ###   plotExpression,data.frame-method plotExpressionDefault
> ###   plotExpressionSCESet
> 
> ### ** Examples
> 
> ## prepare data
> data("sc_example_counts")
> data("sc_example_cell_info")
> pd <- new("AnnotatedDataFrame", data = sc_example_cell_info)
> example_sceset <- newSCESet(countData = sc_example_counts, phenoData = pd)
> example_sceset <- calculateQCMetrics(example_sceset)
> 
> ## default plot
> plotExpression(example_sceset, 1:6, "Mutation_Status")
> 
> ## explore options
> plotExpression(example_sceset, 1:6, x="Mutation_Status", exprs_values="exprs",
+ colour_by="Cell_Cycle", show_violin=TRUE, show_median=TRUE)
> plotExpression(example_sceset, 1:6, x="Mutation_Status", exprs_values="counts",
+ colour_by="Cell_Cycle", show_violin=TRUE, show_median=TRUE)
> 
> ## plot expression against expression values for Gene_0004
> plotExpression(example_sceset, 1:4, "Gene_0004")
> plotExpression(example_sceset, 1:4, "Gene_0004", show_smooth = TRUE)
Warning messages:
1: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  pseudoinverse used at -0.056653
2: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  neighborhood radius 2.8396
3: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  reciprocal condition number  0
4: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  There are other near singularities as well. 7.7447
5: In predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x else if (is.data.frame(newdata)) as.matrix(model.frame(delete.response(terms(object)),  :
  pseudoinverse used at -0.056653
6: In predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x else if (is.data.frame(newdata)) as.matrix(model.frame(delete.response(terms(object)),  :
  neighborhood radius 2.8396
7: In predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x else if (is.data.frame(newdata)) as.matrix(model.frame(delete.response(terms(object)),  :
  reciprocal condition number  0
8: In predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x else if (is.data.frame(newdata)) as.matrix(model.frame(delete.response(terms(object)),  :
  There are other near singularities as well. 7.7447
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>