createPtrSet: Creates a ptrSet object form a directory

View source: R/read_data.R

createPtrSetR Documentation

Creates a ptrSet object form a directory

Description

This function creates a ptrSet-class S4 object. It opens each file and:

  • performs an external calibration by using the mzCalibRef reference masses on the sum spectra every calibrationPeriod second

  • quantifies the primary ion (H3O+ isotope by default) on the average total ion spectrum.

  • calculates expiration on the mzBreathTracer trace. The part of the trace where the intensity is higher than fracMaxTIC * max(trace) is considered as expiration. If fracMaxTIC is different to zero, this step is skipped

  • defines the set of knots for the peak analysis (see detectPeak)

  • provides a default sampleMetadata based on the tree structure of the directory and the acquisition date (a data.frame with file names as row names)

  • If saveDir is not NULL, the returned object will be saved as a .Rdata in saveDir with the setName as name

Usage

createPtrSet(
  dir,
  setName,
  mzCalibRef = c(21.022, 29.013424, 41.03858, 60.0525, 203.943, 330.8495),
  calibrationPeriod = 60,
  fracMaxTIC = 0.8,
  mzBreathTracer = NULL,
  knotsPeriod = 3,
  mzPrimaryIon = 21.022,
  saveDir = NULL,
  maxTimePoint = 900
)

Arguments

dir

character. a directory path which contains several h5 files, possibly organized in subfolder

setName

character. name of the ptrSet object. If 'saveDir' is not null, the object will be saved with this name.

mzCalibRef

vector of the reference mass values; those masses should be accurate, and the corresponding peaks should be of high intensity and 'unique' in a nominal mass interval (without overlapping peaks) to performs calibration. See ?calibration.

calibrationPeriod

in second, coefficient calibration are estimated for each sum spectrum of calibrationPeriod seconds

fracMaxTIC

Fraction (between 0 and 1) of the maximum of the Total Ion Current (TIC) amplitude after baseline removal. Only the part of the spectrum where the TIC intensity is higher than 'fracMaxTIC * max(TIC) ' will be analyzed. If you want to analyze the entire spectrum, set this parameter to 0.

mzBreathTracer

integer: nominal mass of the Extracted Ion Current (EIC) used to compute the expiration time limits. If NULL, the limits will be computed on the Total Ion Current (TIC).

knotsPeriod

period in second (time scale) between two knots for the two dimensional modeling

mzPrimaryIon

Exact mass of the primary ion isotope

saveDir

Directory where the ptrSet object will be saved as .RData. If NULL, nothing will be saved.

maxTimePoint

readRaw parameter, number maximal of time point to read

Value

a ptrSet object with slots :

  • Parameter: list containing the parameters used for createPrtSet, detectPeak and alignTimePeriods functions.

  • sampleMetadata: data frame containing information about the data, with file names in row names

  • mzCalibRef: list containing for each file the masses used for the calibration (see ?ptairMS::calibration for more details)

  • signalCalibRef: mz and intensity +- 0.4Da around the calibration masses

  • errorCalibPpm: list containing for each file the accuracy error in ppm at each calibration masses

  • coefCalib: list containing the calibration coefficients 'a' and 'b' which enable to convert tof to mz for each file (see calibration function for more details.

  • resolution: estimated resolution m / \Delta m for each calibration masses within each file

  • TIC: The Total Ion Current for each file

  • timeLImit: list containing, for each file, a list of two element: the matrix of time limit for each file (if fracMaxTIC is different to zero), and the background index. See timeLimits for more details

  • peakList: list containing for each file an expression set eSet, with m/z peak center, quantification for background and exhaled air in cps, ppb and ncps, and quantity for each time points. See getPeakList for more details.

Examples

library(ptairData)
directory <- system.file('extdata/mycobacteria',  package = 'ptairData')
ptrSet<-createPtrSet(dir=directory,setName='ptrSet'
,mzCalibRef=c(21.022,59.049),
fracMaxTIC=0.9,saveDir= NULL)

camilleroquencourt/ptairMS documentation built on April 24, 2024, 9:03 p.m.