generateSpectrum {Cardinal} | R Documentation |
Generates a simulated spectral signal, or multiple such signals, with peaks of specified intensities.
These functions are provided for backward-compatibility; new code should use simulateSpectrum
and simulateImage
instead.
generateSpectrum(n, peaks = 100, range = c(1001, 20000), centers = seq( from = range[1] + diff(range) / (peaks + 1), to = range[2] - diff(range) / (peaks + 1), length.out = peaks), intensities = runif(peaks, min=0.1, max=1), step = diff(range)/1e3, resolution = 500, noise = 0.05, sd = 0.1, baseline = 2000, auc = TRUE) generateImage(data = factor(1), coord = expand.grid( x = 1:max(1, nrow(data)), y = 1:max(1, ncol(data))), peaks = length(levels(as.factor(data))), delta = 10, as = c("SImageSet", "MSImageSet"), ...)
n |
The number of signals to simulate. |
peaks |
The number of peaks in the signal. |
range |
A pair of numbers specifying the range of continues feature values at which the signal is measured. |
centers |
The values of the singal feature at which peaks occur. |
intensities |
The values of the intensities of the peaks, which could either be heights of the peaks or their area under the curve. |
step |
The step size between measurements in the feature space. |
resolution |
The instrument resolution. This affects the width of the peaks. Higher resolutions produce sharper peaks. |
noise |
A value without scale that indicates the amount of noise in the signal. |
sd |
Standard deviation of the intensities of the peaks. |
baseline |
A value without scale that indicates the shape and size of the baseline. |
auc |
Should the peak heights be influenced by the area under the curve? This reflects fragmentation and limited accuracy at higher mass ranges. If 'FALSE' then the peak heights correspond directly to the provided intensities. |
data |
Either a |
coord |
A |
delta |
The effect size of the difference between peaks differentiating different regions in the image (as specified by |
as |
Should the output object be an |
... |
Additional arguments to pass to |
For generateSpectrum
, a list
with elements:
x
: numeric
, a numeric vector of signal intensities
t
: numeric
, a numeric vector of signal features
For generateImage()
, a SImageSet
or a MSImageSet
.
Kylie A. Bemis
simulateSpectrum
,
simulateImage
# Generate spectra s <- generateSpectrum(1) plot(x ~ t, type="l", data=s) s <- generateSpectrum(1, centers=c(2000,3000), resolution=10, baseline=3000) plot(x ~ t, type="l", data=s) s <- generateSpectrum(1, peaks=2, auc=FALSE, baseline=0) plot(x ~ t, type="l", data=s) # Generate images data <- matrix(c(NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, NA, 0, 1, 1, NA, NA, NA, NA, NA, 1, 0, 0, 1, 1, NA, NA, NA, NA, NA, 0, 1, 1, 1, 1, NA, NA, NA, NA, 0, 1, 1, 1, 1, 1, NA, NA, NA, NA, 1, 1, 1, 1, 1, 1, 1, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA), nrow=9, ncol=9) set.seed(1) x <- generateImage(data) plot(x, pixel=1) image(x, feature=1) coord <- expand.grid(x=1:nrow(data), y=1:ncol(data)) data2 <- as.factor(data[is.finite(data)]) coord2 <- coord[is.finite(data),] set.seed(1) x2 <- generateImage(data=data, coord=coord, as="MSImageSet") plot(x, pixel=1) image(x2, feature=1)