Last data update: 2014.03.03

R: Plot reduced dimension representation of cells
plotReducedDimR Documentation

Plot reduced dimension representation of cells

Description

Plot reduced dimension representation of cells

Usage

plotReducedDim(object, ...)

plotReducedDim.default(df_to_plot, ncomponents = 2, colour_by = NULL,
  shape_by = NULL, size_by = NULL, percentVar = NULL, theme_size = 10,
  legend = "auto")

plotReducedDim.SCESet(object, ncomponents = 2, colour_by = NULL,
  shape_by = NULL, size_by = NULL, theme_size = 10, legend = "auto")

## S4 method for signature 'SCESet'
plotReducedDim(object, ncomponents = 2, colour_by = NULL,
  shape_by = NULL, size_by = NULL, legend = TRUE)

## S4 method for signature 'data.frame'
plotReducedDim(object, ncomponents = 2,
  colour_by = NULL, shape_by = NULL, size_by = NULL, percentVar = NULL,
  legend = TRUE)

Arguments

object

an SCESet object with a non-NULL reducedDimension slot.

...

optional arguments (from those listed above) passed to plotReducedDim.SCESet or plotReducedDim.default

df_to_plot

data.frame containing a reduced dimension represenation of cells and optional metadata for the plot.

ncomponents

numeric scalar indicating the number of principal components to plot, starting from the first principal component. Default is 2. If ncomponents is 2, then a scatterplot of Dimension 2 vs Dimension 1 is produced. If ncomponents is greater than 2, a pairs plots for the top dimensions is produced.

colour_by

character string defining the column of pData(object) to be used as a factor by which to colour the points in the plot.

shape_by

character string defining the column of pData(object) to be used as a factor by which to define the shape of the points in the plot.

size_by

character string defining the column of pData(object) to be used as a factor by which to define the size of points in the plot.

percentVar

numeric vector giving the proportion of variance in expression explained by each reduced dimension. Only expected to be used internally in the plotPCA function.

theme_size

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

legend

character, specifying how the legend(s) be shown? Default is "auto", which hides legends that have only one level and shows others. Alternatives are "all" (show all legends) or "none" (hide all legends).

Details

The function plotReducedDim.default assumes that the first ncomponents columns of df_to_plot contain the reduced dimension components to plot, and that any subsequent columns define factors for colour_by, shape_by and size_by in the plot.

Value

a ggplot plot object

Examples

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)
drop_genes <- apply(exprs(example_sceset), 1, function(x) {var(x) == 0})
example_sceset <- example_sceset[!drop_genes, ]

reducedDimension(example_sceset) <- prcomp(t(exprs(example_sceset)), scale. = TRUE)$x
plotReducedDim(example_sceset)
plotReducedDim(example_sceset, colour_by="Cell_Cycle")
plotReducedDim(example_sceset, colour_by="Cell_Cycle", shape_by="Treatment")
plotReducedDim(example_sceset, colour_by="Cell_Cycle", size_by="Treatment")
plotReducedDim(example_sceset, ncomponents=5)
plotReducedDim(example_sceset, ncomponents=5, colour_by="Cell_Cycle", shape_by="Treatment")


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/plotReducedDim.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotReducedDim
> ### Title: Plot reduced dimension representation of cells
> ### Aliases: plotReducedDIm plotReducedDim plotReducedDim,SCESet-method
> ###   plotReducedDim,data.frame-method plotReducedDim.SCESet
> ###   plotReducedDim.default
> 
> ### ** Examples
> 
> 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)
> drop_genes <- apply(exprs(example_sceset), 1, function(x) {var(x) == 0})
> example_sceset <- example_sceset[!drop_genes, ]
> 
> reducedDimension(example_sceset) <- prcomp(t(exprs(example_sceset)), scale. = TRUE)$x
> plotReducedDim(example_sceset)
> plotReducedDim(example_sceset, colour_by="Cell_Cycle")
> plotReducedDim(example_sceset, colour_by="Cell_Cycle", shape_by="Treatment")
> plotReducedDim(example_sceset, colour_by="Cell_Cycle", size_by="Treatment")
Warning message:
Using size for a discrete variable is not advised. 
> plotReducedDim(example_sceset, ncomponents=5)
> plotReducedDim(example_sceset, ncomponents=5, colour_by="Cell_Cycle", shape_by="Treatment")
> 
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>