Generate 2 dimensional or feature distribution plots to illustrate
localistation clusters. In plot2D, rows containing
NA values are removed prior to dimention reduction.
Feature meta-data label (fData column name) defining
the groups to be differentiated using different colours. Default
is markers. Use NULL to suppress any colouring.
fpch
Featre meta-data label (fData column name) desining
the groups to be differentiated using different point symbols.
unknown
A character (default is "unknown")
defining how proteins of unknown/un-labelled localisation are
labelled.
dims
A numeric of length 2 defining the dimensions
to be plotted. Always 1:2 for MDS.
score
A numeric specifying the minimum organelle assignment score
to consider features to be assigned an organelle. (not yet implemented).
method
A character describe how to transform the
data or what to plot. One of "PCA" (default),
"MDS", "kpca" or "t-SNE", defines what
dimensionality reduction is applied: principal component
analysis (see prcomp), classical
multidimensional scaling (see cmdscale), kernel
PCA (see kernlab::kpca) or t-SNE (see
tsne::tsne). "scree" can also be used to produce
a scree plot. If none is used, the data is plotted as is,
i.e. without any transformation. In this case, object
can either be an MSnSet or a matrix (as
invisibly returned by plot2D). This enables to
re-generate the figure without computing the dimensionality
reduction over and over again, which can be time consuming for
certain methods. Available methods are listed in
plot2Dmethods. If object is a matrix, an
MSnSet containing the feature metadata must be provided
in methargs (see below for details).
methargs
A list of arguments to be passed when
method is called. If missing, the data will be scaled
and centred prior to PCA. If method = "none" and
object is a matrix, then the first and only
argument of methargs must be an MSnSet with
matching features with object.
axsSwitch
A logical indicating whether the axes
should be switched.
mirrorX
A logical indicating whether the x axis
should be mirrored?
mirrorY
A logical indicating whether the y axis
should be mirrored?
col
A character of appropriate length defining colours.
pch
A character of appropriate length defining point character.
cex
Character expansion.
index
A logical (default is FALSE, indicating of the
feature indices should be plotted on top of the symbols.
idx.cex
A numeric specifying the character expansion
(default is 0.75) for the feature indices. Only relevant when index
is TRUE.
identify
A logical (default is TRUE) defining if
user interaction will be expected to identify individual data
points on the plot. See also identify.
plot
A logical defining if the figure should be plotted.
Useful when retrieving data only. Default is TRUE.
...
Additional parameters passed to plot and
points.
Details
Note that plot2D has been update in version 1.3.6 to
support more organelle classes than colours defined in
getStockcol. In such cases, the default
colours are recycled using the default plotting characters
defined in getStockpch. See the example for
an illustration. The alpha argument is also
depreciated in version 1.3.6. Use setStockcol to set
colours with transparency instead. See example below.
Version 1.11.3: to plot data as is, i.e. without any
transformation, method can be set to "none" (as
opposed to passing pre-computed values to method as a
matrix, in previous versions). If object is an
MSnSet, the untransformed values in the assay data
will be plotted. If object is a matrix with
coordinates, then a matching MSnSet must be passed to
methargs.
Value
Used for its side effects of generating a plot.
Invisibly returns the 2d data.
Author(s)
Laurent Gatto <lg390@cam.ac.uk>
See Also
addLegend to add a legend to plot2D
figures and plotDist for alternative graphical
representation of quantitative organelle proteomics
data. plot2Ds to overlay 2 data sets on the same
PCA plot.
Examples
library("pRolocdata")
data(dunkley2006)
plot2D(dunkley2006, fcol = NULL)
## available methods
plot2Dmethods
plot2D(dunkley2006, fcol = NULL, method = "kpca")
plot2D(dunkley2006, fcol = NULL, method = "kpca",
methargs = list(kpar = list(sigma = 1)))
plot2D(dunkley2006, fcol = "markers")
addLegend(dunkley2006,
fcol = "markers",
where = "topright",
cex = 0.5, bty = "n", ncol = 3)
title(main = "plot2D example")
## Using transparent colours
setStockcol(paste0(getStockcol(), "80"))
plot2D(dunkley2006, fcol = "markers")
## New behavious in 1.3.6 when not enough colours
setStockcol(c("blue", "red", "green"))
getStockcol() ## only 3 colours to be recycled
getMarkers(dunkley2006)
plot2D(dunkley2006)
## reset colours
setStockcol(NULL)
plot2D(dunkley2006, method = "none") ## plotting along 2 first fractions
plot2D(dunkley2006, dims = c(3, 5), method = "none") ## plotting along fractions 3 and 5
## pre-calculate PC1 and PC2 coordinates
pca <- plot2D(dunkley2006, plot=FALSE)
head(pca)
plot2D(pca, method = "none", methargs = list(dunkley2006))
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(pRoloc)
Loading required package: MSnbase
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
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: mzR
Loading required package: Rcpp
Loading required package: BiocParallel
Loading required package: ProtGenerics
This is MSnbase version 1.20.7
Read '?MSnbase' and references therein for information
about the package and how to get started.
Attaching package: 'MSnbase'
The following object is masked from 'package:stats':
smooth
The following object is masked from 'package:base':
trimws
Loading required package: MLInterfaces
Loading required package: annotate
Loading required package: AnnotationDbi
Loading required package: stats4
Loading required package: IRanges
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: XML
Loading required package: cluster
This is pRoloc version 1.12.4
Read '?pRoloc' and references therein for information
about the package and how to get started.
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/pRoloc/plot2D.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot2D
> ### Title: Plot organelle assignment data and results.
> ### Aliases: plot2D plot2Dmethods
>
> ### ** Examples
>
> library("pRolocdata")
This is pRolocdata version 1.10.0.
Use 'pRolocdata()' to list available data sets.
> data(dunkley2006)
> plot2D(dunkley2006, fcol = NULL)
> ## available methods
> plot2Dmethods
[1] "PCA" "MDS" "kpca" "t-SNE" "none" "scree"
> plot2D(dunkley2006, fcol = NULL, method = "kpca")
> plot2D(dunkley2006, fcol = NULL, method = "kpca",
+ methargs = list(kpar = list(sigma = 1)))
> plot2D(dunkley2006, fcol = "markers")
> addLegend(dunkley2006,
+ fcol = "markers",
+ where = "topright",
+ cex = 0.5, bty = "n", ncol = 3)
> title(main = "plot2D example")
> ## Using transparent colours
> setStockcol(paste0(getStockcol(), "80"))
> plot2D(dunkley2006, fcol = "markers")
> ## New behavious in 1.3.6 when not enough colours
> setStockcol(c("blue", "red", "green"))
> getStockcol() ## only 3 colours to be recycled
[1] "blue" "red" "green"
> getMarkers(dunkley2006)
organelleMarkers
ER lumen ER membrane Golgi Mitochondrion PM
14 45 28 55 46
Plastid Ribosome TGN unknown vacuole
20 19 13 428 21
> plot2D(dunkley2006)
Not enough colours: using colours and pch.
> ## reset colours
> setStockcol(NULL)
> plot2D(dunkley2006, method = "none") ## plotting along 2 first fractions
> plot2D(dunkley2006, dims = c(3, 5), method = "none") ## plotting along fractions 3 and 5
> ## pre-calculate PC1 and PC2 coordinates
> pca <- plot2D(dunkley2006, plot=FALSE)
> head(pca)
PC1 (64.36%) PC2 (22.34%)
AT1G09210 -4.734261 -0.8204175
AT1G21750 -4.615276 -1.1891468
AT1G51760 -4.770573 -1.6292717
AT1G56340 -5.318056 -0.9972462
AT2G32920 -5.135122 -1.5283630
AT2G47470 -4.899410 -0.8145343
> plot2D(pca, method = "none", methargs = list(dunkley2006))
>
>
>
>
>
> dev.off()
null device
1
>