Description Usage Arguments Details Value Note Author(s) See Also Examples
A flexible and convenient function to extract raw data from a NetCDF file format
4 using time ranges and m/z ranges or values. This is a better (and faster)
alternative to the old peakCDFextraction()
function, which reads the whole CDF
into memory, specially when only sections of the CDF are needed.
1 | ncdf4_data_extract(cdfFile, massValues, timeRange, useRT = FALSE)
|
cdfFile |
A path to a NetCDF file format 4. |
massValues |
A numeric vector representing m/z values. |
timeRange |
A numeric vector of length 2 representing the lower and upper time limits. |
useRT |
Logical. If |
The function takes a NetCDF format 4 generated by "TargetSearch" and extracts raw intensity values from given m/z ion traces within a given time range. The time range can be in seconds or arbitrary retention time index units. For the latter case, the function expects a time corrected CDF file.
If the given time range is out of range, a NULL
value will be returned. In contrast,
if the m/z values are out of range, then zeros will be returned for out of range masses
(provided that the time range is not out of range). If timeRange
is missing, then
the whole time range. Similarly, if massRange
is missing, then all the masses are
extracted. If both are missing, the function behaves as peakCDFextraction()
, but
the output (a named list) uses slightly different names.
The NetCDF must be have been previously converted to the custom "TargetSearch" format,
otherwise an error will be raised. See ncdf4_convert()
for the convertion.
A named list with the following components.
Time
Numeric vector: the retention time in seconds
Index
Numeric vector: the retention time index (or zero if the file was
was not retention time corrected
Intensity
Matrix: Rows are the retention times (or scans) and columns are masses.
massRange
Numeric vector of length 2: the mass range of the CDF
An error will be produced for invalid files. Also, this function is intended to be used internally, but it is exposed for convinience, for example, to create custom plots.
Alvaro Cuadros-Inostroza
ncdf4_convert()
, peakCDFextraction()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
# set a NCDF-4 file
nc4file <- "/path/to/netcdf4.nc4"
# extract all data (behaves like peakCDFextraction)
data <- ncdf4_data_extract(nc4file)
# extract only certain m/z values
data <- ncdf4_data_extract(nc4file, massValues=c(116, 192))
# to use mass ranges, use the colon (:) operator for example
data <- ncdf4_data_extract(nc4file, massValues=c(120:130, 200, 203:209))
# restrict extraction to a retention index interval
data <- ncdf4_data_extract(nc4file, massValues=c(116, 192),
timeRange=c(200000, 220000))
# same, but using retention time in seconds.
data <- ncdf4_data_extract(nc4file, massValues=c(116, 192),
timeRange=c(200, 300), useRT=TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.