R: Highlight features of interest on a plot2D figure
highlightOnPlot
R Documentation
Highlight features of interest on a plot2D figure
Description
Highlights a set of features of interest given as a
FeaturesOfInterest instance on a PCA plot produced by
codeplot2D. If none of the features of interest are found in the
MSnset's featureNames, an warning is thrown.
The main dataset described as an MSnSet or a
matrix with the coordinates of the features on the PCA
plot produced (and invisibly returned) by plot2D.
foi
An instance of FeaturesOfInterest,
or, alternatively, a character of feautre names.
labels
A character of length 1 with a feature
variable name to be used to label the features of
interest. This is only valid if object is an
MSnSet. Alternatively, if TRUE, then
featureNames(object) (or coderownames(object), if
object is a matrix) are used. Default is
missing, which does not add any label.s
args
A named list of arguments to be passed to
plot2D if the PCA coordinates are to be
calculated. Ignored if the PCA coordinates are passed
directly, i.e. object is a matrix.
...
Additional parameters passed to points.
Value
NULL; used for its side effects.
Author(s)
Laurent Gatto
Examples
library("pRolocdata")
data("tan2009r1")
x <- FeaturesOfInterest(description = "A test set of features of interest",
fnames = featureNames(tan2009r1)[1:10],
object = tan2009r1)
## using FeaturesOfInterest or feature names
par(mfrow = c(2, 1))
plot2D(tan2009r1)
highlightOnPlot(tan2009r1, x)
plot2D(tan2009r1)
highlightOnPlot(tan2009r1, featureNames(tan2009r1)[1:10])
.pca <- plot2D(tan2009r1)
head(.pca)
highlightOnPlot(.pca, x, col = "red")
highlightOnPlot(tan2009r1, x, col = "red", cex = 1.5)
highlightOnPlot(tan2009r1, x, labels = TRUE)
.pca <- plot2D(tan2009r1, dims = c(1, 3))
highlightOnPlot(.pca, x, pch = "+", dims = c(1, 3))
highlightOnPlot(tan2009r1, x, args = list(dims = c(1, 3)))
.pca2 <- plot2D(tan2009r1, mirrorX = TRUE, dims = c(1, 3))
## previous pca matrix, need to mirror X axis
highlightOnPlot(.pca, x, pch = "+", args = list(mirrorX = TRUE))
## new pca matrix, with X mirrors (and 1st and 3rd PCs)
highlightOnPlot(.pca2, x, col = "red")
plot2D(tan2009r1)
highlightOnPlot(tan2009r1, x)
highlightOnPlot(tan2009r1, x, labels = TRUE, pos = 3)
highlightOnPlot(tan2009r1, x, labels = "Flybase.Symbol", pos = 1)
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/highlightOnPlot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: highlightOnPlot
> ### Title: Highlight features of interest on a plot2D figure
> ### Aliases: highlightOnPlot
>
> ### ** Examples
>
> library("pRolocdata")
This is pRolocdata version 1.10.0.
Use 'pRolocdata()' to list available data sets.
> data("tan2009r1")
> x <- FeaturesOfInterest(description = "A test set of features of interest",
+ fnames = featureNames(tan2009r1)[1:10],
+ object = tan2009r1)
>
> ## using FeaturesOfInterest or feature names
> par(mfrow = c(2, 1))
> plot2D(tan2009r1)
> highlightOnPlot(tan2009r1, x)
> plot2D(tan2009r1)
> highlightOnPlot(tan2009r1, featureNames(tan2009r1)[1:10])
>
> .pca <- plot2D(tan2009r1)
> head(.pca)
PC1 (58.53%) PC2 (29.96%)
P20353 0.2103374 1.6959266
P53501 -0.4940607 1.6207386
Q7KU78 -1.1794311 -0.7242185
P04412 0.6128549 0.3944441
Q7KJ73 0.1866756 -0.3007028
Q7JZN0 2.0228016 -1.3087061
> highlightOnPlot(.pca, x, col = "red")
> highlightOnPlot(tan2009r1, x, col = "red", cex = 1.5)
> highlightOnPlot(tan2009r1, x, labels = TRUE)
>
> .pca <- plot2D(tan2009r1, dims = c(1, 3))
> highlightOnPlot(.pca, x, pch = "+", dims = c(1, 3))
Warning message:
In plot.xy(xy.coords(x, y), type = type, ...) :
"dims" is not a graphical parameter
> highlightOnPlot(tan2009r1, x, args = list(dims = c(1, 3)))
>
> .pca2 <- plot2D(tan2009r1, mirrorX = TRUE, dims = c(1, 3))
> ## previous pca matrix, need to mirror X axis
> highlightOnPlot(.pca, x, pch = "+", args = list(mirrorX = TRUE))
> ## new pca matrix, with X mirrors (and 1st and 3rd PCs)
> highlightOnPlot(.pca2, x, col = "red")
>
> plot2D(tan2009r1)
> highlightOnPlot(tan2009r1, x)
> highlightOnPlot(tan2009r1, x, labels = TRUE, pos = 3)
> highlightOnPlot(tan2009r1, x, labels = "Flybase.Symbol", pos = 1)
>
>
>
>
>
> dev.off()
null device
1
>