Learn R Programming

MALDIquant (version 1.2)

labelPeaks-methods: Draws peak labels to plot.

Description

labelPeaks draws the corresponding mass values on top of the peaks stored in a MassPeaks object to a plot.

Usage

## S3 method for class 'MassPeaks':
labelPeaks(object, 
    index,
    mass, tolerance=0.002,
    digits=3, underline=TRUE, 
    verticalOffset=abs(diff(par("usr")[3:4]))*0.0125,
    absoluteVerticalPos,
    adj=c(0.5, 0), cex=0.7, family="sans", 
    ...)

Arguments

object
MassPeaks object.
index
vector, indices of peaks to label.
mass
vector, mass of peaks to label.
tolerance
double, maximal deviation of a peak position (mass) to be considered.
digits
integer, number of decimal places.
underline
logical, underline peak values?
verticalOffset
numeric, move label vertically (relative to peak height).
absoluteVerticalPos
numeric, absolute y value for the label. If missing verticalOffset is used.
adj
numeric, adjust text to the left, center, right and top, center, bottom; see text.
cex
numeric, font size, see par.
family
name of font family, see par.
...
arguments to be passed to text.

See Also

MassPeaks, plot,AbstractMassObject,missing-method

Examples

Run this code
## load library
library("MALDIquant");

## create a MassPeaks object from scratch
p <- createMassPeaks(mass=1:20, intensity=sample(x=100:10000, size=20), 
                     metaData=list(name="example"));

## plot peaks
plot(p);

## label the first 5 peaks
labelPeaks(p, index=1:5);

## label all peaks in mass range 15 to 20 
labelPeaks(p, mass=15:20, underline=FALSE);

## label highest peaks (top 5)
top5 <- intensity(p) %in% sort(intensity(p), decreasing=TRUE)[1:5];
labelPeaks(p, index=top5, col="red");

Run the code above in your browser using DataLab