plotSpectra: Plot Multiple Spectra on a Single Plot

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plotMSMS.R

Description

This is the main function to plot multiple mass spectra on one plot, with many options to control the output.

Usage

1
2
3
4
5
6
plotSpectra(mz, int, main, labels=NULL,labelSpec=1,label_mz=NA,
label_int=NA,mz_a=NA,int_a=NA, absInt=FALSE, logInt=FALSE, mz_b=NA,int_b=NA,
smiles="",kekulise=TRUE,legend=c("spec1","spec2","spec3"),
xlim=NULL,ylim=NULL, yfactor=2.5, line_colour=c("black","red","green"),
line_type=c("solid","dashed","dotdash"),line_width=c(2,2,1),
chem2express=FALSE, srt=60, pos=4,offset=-0.2)

Arguments

mz

Vector containing mz values (x) to plot first.

int

Vector containing intensity values (y) to plot first.

main

Title for the plot.

labels

Vector containing labels for selected peaks. If NULL, no labels are plotted.

labelSpec

Indicates which spectrum to use for label coordinates. Must be same length as labels to avoid recycling labels. If 1, mz and int are used, if 2 then mz_a and int_a, if 3, then mz_b and int_b. Parameters label_mz and label_int take precedence.

label_mz

Values defining starting x coordinates for labels.

label_int

Values defining starting y coordinates for labels.

mz_a

Vector containing mz values for second spectrum.

int_a

Vector containing intensity values for second spectrum.

absInt

If TRUE, absolute intensity values are used. Be careful that all spectra match! If FALSE, relative intensities are calculated on individual spectra, scaled to 1000.

logInt

If FALSE, intensity values are used as is. If TRUE, log values are used; this can be useful to find small peaks.

mz_b

Vector containing mz values for third spectrum.

int_b

Vector containing intensity values for third spectrum.

smiles

SMILES code of the structure to plot. Leave empty for no structure.

kekulise

Controls aromaticity detection of smiles. Default TRUE should work best with rcdk>3.4.1. Try FALSE if rings and double bonds appear together in aromatic rings.

legend

Vector containing legend entries.

xlim

Option to control x-axis limits. If NULL, xlim=c(0,1.1*max(all_mz))

ylim

Option to control y-axis limits. If NULL, ylim=c(0,yfactor*max(all_int)) unless log scale is used, where ylim=c(-1, yfactor+8).

yfactor

Scaling factor for y-axis. Default 2.5 leaves ample space for structure, annotations and legend. Reduce for peaks only.

line_colour

Optional vector to re-define default line colours.

line_type

Optional vector to re-define default line type.

line_width

Optional vector to re-define default line widths.

chem2express

If TRUE, uses chemistry2expression to create subscript numbers. Any + or - are removed to avoid errors. If FALSE, labels are printed as is.

srt

Optional parameter to adjust srt value for labels.

pos

Optional parameter to adjust pos value for labels.

offset

Optional parameter to adjust offset value for labels.

Details

For controlling label orientation, the following settings are useful: Default (angle): srt=60, pos=4, offset=-0.2; Vertical above peak: srt=90, pos=4, offset=0; Horizontal, centred above peak: srt=0, pos=3, offset=0.2.

To avoid overlapping labels, use trimAnnotation.

Value

Returns a plot in the current plotting device.

Author(s)

Emma Schymanski <emma.schymanski@uni.lu>

See Also

plot, renderSMILES.rcdk, chemistry2expression, text, trimAnnotation.

Examples

1
2
3
4
5
6
7
mz_1 <- c(58.0287, 111.0441, 168.0655, 210.1125)
int_1 <- c(23.0000, 999.0000, 843.5855, 999.0000)
labels_1 <- c("C2H4NO", "C6H7O2", "C8H10NO3", "C11H16NO3")
smiles_1 <- "O=C(Oc1ccccc1OC(C)C)NC"
plotSpectra(mz_1, int_1, main="test spec",labels=labels_1, labelSpec=1, smiles=smiles_1)
plotSpectra(mz_1, int_1, main="test spec",labels=labels_1, labelSpec=1, smiles=smiles_1,
chem2express=TRUE, mz_a=mz_1, int_a = int_1, legend=c("spec1","spec1 again"))

schymane/ReSOLUTION documentation built on May 22, 2021, 3:41 a.m.