writeIntensity {MALDIrppa}R Documentation

Write intensity matrix in different formats

Description

This function writes an intensity matrix as generated by intensityMatrix into a file in the R, csv, NEXUS or FASTA formats. For NEXUS format it allows to specify weights for peaks.

Usage

writeIntensity(x, filename = "intMatrix", format = c("R", "csv", "NEXUS", "FASTA"),
               binary = FALSE, labels = NULL, weights=NULL, ...)

Arguments

x

Intensity matrix as obtained from intensityMatrix.

filename

A character string specifying a name for the destination file (filename extension not required).

format

One of R (default .RData file), text (comma-separated .csv file), NEXUS (.nex file) or FASTA (.fas file).

binary

Logical value. If TRUE, a binary version (1: peak presence, 0: peak absence) of x is saved (default FALSE).

labels

Optional vector of ID labels for the samples.

weights

Optional numeric vector of peak weights (NEXUS format).

...

Additional arguments.

Details

This is a wrapper function to simplify the writing of an intensity matrix in different formats while adding some extra features. It includes the common NEXUS and FASTA formats as an extension of functions in the ape package to handle peak intensity data. It also allows for taxa/sample pre-computed peak weights to be included in the NEXUS file. It checks whether the names meet NEXUS name conventions and gives them adequate format if not. A binary intensity matrix is always internally generated (binary = TRUE) when either the NEXUS or FASTA format is chosen. If any, NA values in x are assumed to denote zero intensity/peak absence and are then converted into zeros.

Value

No return value, file in selected format created on destination folder.

Examples

# Load example data

data(spectra) # list of MassSpectra class objects

# Some pre-processing

spectra <- screenSpectra(spectra)$fspectra
spectra <- transformIntensity(spectra, method = "sqrt")
spectra <- wavSmoothing(spectra)
spectra <- removeBaseline(spectra)
peaks <- detectPeaks(spectra)
peaks <- alignPeaks(peaks, minFreq = 0.8)

# Intensity matrix

int <- intensityMatrix(peaks)

# Save as R file (saved to a temporary location as an example)

writeIntensity(int, file = file.path(tempdir(), "int"))

# Save as binary NEXUS file (saved to a temporary location as an example)

writeIntensity(int, file = file.path(tempdir(),"int.binary"),
               format = "NEXUS", interleaved = FALSE)


[Package MALDIrppa version 1.1.0-2 Index]