ncdf4_convert | R Documentation |
Convert from NetCDF format 3 into a custom TargetSearch NetCDF format 4. The new NetCDF just contains the raw data in a matrix format in order to allow easier and faster data manipulation.
ncdf4_convert(cdfFile, outFile = NULL, force = FALSE,
baseline = FALSE, ...)
cdfFile |
The NetCDF file to be converted |
outFile |
The new output file. If |
force |
Logical. Set to |
baseline |
Logical. Whether or not baseline correct the input file. |
... |
extra options passed to |
Starting from version 1.42.0, TargetSearch introduces a custom NetCDF file which is used for faster and easier data manipulation. This means, ion traces within a retention time can be quickly extracted, which if often required before plotting. Formerly, this process required parsing the whole file before the data could be extracted.
Note that this function only takes one file at the time. To convert many files at the
same time, see the function ncdf4_convert_from_path()
or the high level method
ncdf4Convert()
. Alternatively, you can call this function in a loop or
using the lapply
family of functions.
Keep in mind this function is intended for internal use (or advanced users); it is
exported for convenience. Using the method ncdf4Convert()
is recommended.
A string. The path to the converted file or invisible.
The structure of the NetCDF format 4 is straightforward and the variables and attributes are self-evident. The following variables are defined.
retention_time
is a vector representing the retention time in seconds (double).
retention_index
is a vector representing the retention time indices (double).
If missing, then the variable contains zeros. Its length is equal to the length
of retention_time
.
mass_range
is vector of length two containing the minimum and maximum m/z
values (integer).
intensity
is matrix of intensity values (integer) where columns represent
ion traces and rows are scans. The dimensions are length of "retention time"
times the number of ions, i.e., mass max - mass min + 1.
In addition, the following attributes are defined. Note that only creator
and
version
are mandatory.
creator
a string equal to "TargetSearch" (for identification purposes).
version
file format version (string). Currently "1.1".
time_corrected
(optional) a flag (short integer) to indicate RI correction.
If missing it defaults to false
.
baseline_corrected
(optional) a flag (short integer) to indicate that the file was
baseline corrected by TargetSearch. If missing it defaults to false
.
Currently, it is not possible to reconstruct the original NetCDF file from the converted file, especially if nominal mass or baseline correction was applied. On the other hand, if the NetCDF files are exported from custom chromatogram files (such as thermo raw files or LECO peg files), then the NetCDF 3 files can be deleted safely as there is always a way to recover them.
Alvaro Cuadros-Inostroza
ncdf4Convert()
, ncdf4_convert_from_path()
, baseline()
require(TargetSearchData)
# get files from package TargetSearchData
cdfpath <- tsd_data_path()
# choose any file
cdf <- file.path(cdfpath, '7235eg04.cdf')
nc4 <- '7235eg04.nc4' # save file in current path
# run the function
ret <- ncdf4_convert(cdf, nc4)
# the output should match the output file
stopifnot(ret == nc4)
# Use mapply to convert many files at the same time.
cdf <- paste0('7235eg0', 6:8, '.cdf')
nc4 <- paste0('7235eg0', 6:8, '.nc4')
ret <- mapply(ncdf4_convert, file.path(cdfpath, cdf), nc4)
stopifnot(ret == nc4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.