| Title: | Chromatographic File Converter |
|---|---|
| Description: | Reads chromatograms from binary formats into R objects. Currently supports conversion of 'Agilent ChemStation', 'Agilent MassHunter', 'Agilent OpenLab', 'Shimadzu LabSolutions', 'ThermoRaw', 'Varian Workstation', and 'Waters Empower' files as well as various other formats. In addition to its internal parsers, chromConverter contains bindings to parsers in external libraries, such as 'Aston' <https://github.com/bovee/aston>, 'Entab' <https://github.com/bovee/entab>, 'rainbow' <https://rainbow-api.readthedocs.io/>, and 'ThermoRawFileParser' <https://github.com/compomics/ThermoRawFileParser>. The suggested packages 'entab' and 'chromConverterExtraTests' are not on CRAN: both are available from the repository given in 'Additional_repositories', and the latest test fixtures can also be installed from <https://github.com/ethanbass/chromConverterExtraTests>. |
| Authors: | Ethan Bass [aut, cre] (ORCID: <https://orcid.org/0000-0002-6175-6739>), James Dillon [ctb, cph] (Author and copyright holder of source code adapted from the 'Chromatography Toolbox' for parsing 'Agilent' FID files.), Evan Shi [ctb, cph] (Author and copyright holder of source code adapted from 'rainbow' for parsing 'Agilent' UV files.), Roderick Bovee [ctb, cph] (Author and copyright holder of source code adapted from 'Aston' for parsing 'Agilent ChemStation' register files.) |
| Maintainer: | Ethan Bass <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.11.2.9000 |
| Built: | 2026-10-29 10:22:16 UTC |
| Source: | https://github.com/ethanbass/chromConverter |
Attaches the columns of a table to the chromatograms of a chrom_list as
metadata fields, matching each row to a sample by name. The new fields can
then be used by subset.chrom_list and requested from extract_metadata.
Where an element holds several chromatograms, such as the traces
read_agilent_d returns for each .D directory, every one of them gets the
sample's values.
add_metadata(chrom_list, metadata, by = "name", overwrite = FALSE)add_metadata(chrom_list, metadata, by = "name", overwrite = FALSE)
chrom_list |
A |
metadata |
A |
by |
The column of |
overwrite |
Whether a column may replace a field that chromConverter
reads from the file, such as |
chrom_list with the columns of metadata attached to its
chromatograms, and their names recorded in an added_metadata attribute,
from which chromatographR's get_peaktable fills its sample_meta. A
sample without a row in metadata is left unchanged, with a warning.
extract_metadata, subset.chrom_list
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) meta <- data.frame(name = c("MEOH", "BENZOS_1000PPM", "BENZOS_500PPM", "BENZOS_250PPM", "BENZOS_125PPM", "BENZOS_62,5PPM", "BENZOS_31,25PPM", "BENZOS_16PPM", "BENZOS_8PPM", "BENZOS_4PPM"), ppm = c(0, 1000 / 2^(0:8))) chroms <- add_metadata(chroms, meta) extract_metadata(chroms, what = "ppm") names(subset(chroms, ppm >= 250))path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) meta <- data.frame(name = c("MEOH", "BENZOS_1000PPM", "BENZOS_500PPM", "BENZOS_250PPM", "BENZOS_125PPM", "BENZOS_62,5PPM", "BENZOS_31,25PPM", "BENZOS_16PPM", "BENZOS_8PPM", "BENZOS_4PPM"), ppm = c(0, 1000 / 2^(0:8))) chroms <- add_metadata(chroms, meta) extract_metadata(chroms, what = "ppm") names(subset(chroms, ppm >= 250))
An ASCII export from 'Shimadzu LabSolutions' of a GC-FID run (GC-2014) of an
n-alkane ladder with nonadecane (C19) added, sampled by solid-phase
microextraction, holding its peak table of 83 peaks and the chromatogram,
recorded every 40 ms for 44 minutes. Find it with
system.file("extdata", "alkane_ladder.txt", package = "chromConverter").
Released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/).
Andrew W. Legan (https://orcid.org/0000-0001-7049-9837). The
binary file of the same run is FS19_214.gcd in 'chromConverterExtraTests'.
A calibration series of a mixed benzoxazinoid standard, run by HPLC with an
'Agilent' diode array detector (G1315A), as ten 'ChemStation' .D
directories in extdata. Find them with
system.file("extdata", "benzoxazinoid_standards", package = "chromConverter").
BENZOS_1000PPM.D to BENZOS_4PPM.D: nine twofold dilutions from 1000
ppm, injected between 20 and 22 June 2023. The names round the last three,
which are 15.625, 7.8125 and 3.90625 ppm.
MEOH.D: a methanol blank, run with the same method on 15 June 2023.
Each directory holds the 254 nm trace (dad1A.ch) and the 'ChemStation'
report (Report.TXT). BENZOS_250PPM.D also holds the traces at 230, 320,
360 and 210 nm (dad1B.ch to dad1E.ch), and the pump's pressure, flow
and solvent composition through the run (LCDIAG.REG), which
read_agilent_d returns with what = "instrument".
The standard gives four peaks at 254 nm, eluting in the 250 ppm run at 12.5 (DIBOA), 19.1 (DIMBOA), 21.0 (BOA) and 28.2 minutes (MBOA).
These files are released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/).
vignette("chromConverter"), which works through these files.
Converts chromatography data files using entab parsers. 'entab' detects the file format itself. Mass spectra are always returned in long format.
call_entab( path, data_format = c("wide", "long"), format_out = c("matrix", "data.frame", "data.table"), format_in = "", read_metadata = TRUE, metadata_format = c("chromconverter", "raw") )call_entab( path, data_format = c("wide", "long"), format_out = c("matrix", "data.frame", "data.table"), format_in = "", read_metadata = TRUE, metadata_format = c("chromconverter", "raw") )
path |
Path to file. |
data_format |
Whether to return data in |
format_out |
Class of output. Either |
format_in |
Format of the file, used only to read the metadata that
'entab' does not: those of 'ChemStation' formats (any value containing
|
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
A chromatogram in the format specified by the format_out and
data_format arguments.
Other external parsers:
call_openchrom(),
call_rainbow(),
read_thermoraw(),
sp_converter(),
uv_converter()
## Not run: call_entab("path/to/file.uv", format_in = "chemstation_uv") ## End(Not run)## Not run: call_entab("path/to/file.uv", format_in = "chemstation_uv") ## End(Not run)
Converts files with the OpenChrom command-line interface, then reads the converted files back into R. OpenChrom removed the command-line interface in version 1.5.0, and Lablicate no longer distributes older versions, so this function works only with an existing installation of OpenChrom 1.4 or earlier. It is deprecated for that reason.
call_openchrom( files, path_out = NULL, format_in, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), export_format = c("mzml", "csv", "cdf", "animl"), return_paths = FALSE, verbose = getOption("verbose") )call_openchrom( files, path_out = NULL, format_in, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), export_format = c("mzml", "csv", "cdf", "animl"), return_paths = FALSE, verbose = getOption("verbose") )
files |
Path to files. |
path_out |
Directory to export converted files. Defaults to |
format_in |
Either |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
export_format |
Either |
return_paths |
Logical. If |
verbose |
Logical. Whether to print output from OpenChrom to the console. |
The call_openchrom function works by creating an xml batchfile
and feeding it to the OpenChrom command-line interface. OpenChrom batchfiles
consist of InputEntries (specifying the files you want to convert) and
ProcessEntries (specifying what you want to do to the files). The parsers
are organized into broad categories by detector-type and output format. The
detector-types are msd (mass selective detectors), csd (current selective
detectors, e.g., FID, ECD, NPD), and wsd (wavelength selective detectors,
e.g., DAD, and UV/VIS). Thus, when calling the OpenChrom parsers, one of
these three options must be specified using the format_in argument.
If return_paths is FALSE, a list with one chromatogram per file,
read back with read_mzml, read_cdf or read.csv
according to export_format. format_out and data_format apply only to
cdf files, except that format_out = "matrix" also converts csv files.
animl files cannot be read back,
so use return_paths = TRUE for them. If return_paths is TRUE, a
character vector of paths to the newly created files.
Chromatograms are exported in the format specified
by export_format to the folder specified by path_out.
Activating the OpenChrom command-line deactivates the graphical user interface (GUI). To keep using the GUI, install a second copy of OpenChrom and call that one from R.
Ethan Bass
Wenig, Philip and Odermatt, Juergen. OpenChrom: A Cross-Platform Open Source Software for the Mass Spectrometric Analysis of Chromatographic Data. BMC Bioinformatics 11, no. 1 (July 30, 2010): 405. doi:10.1186/1471-2105-11-405.
Other external parsers:
call_entab(),
call_rainbow(),
read_thermoraw(),
sp_converter(),
uv_converter()
## Not run: call_openchrom("path/to/file.RAW", format_in = "msd", export_format = "mzml") ## End(Not run)## Not run: call_openchrom("path/to/file.RAW", format_in = "msd", export_format = "mzml") ## End(Not run)
Parse 'Agilent' or 'Waters' files with rainbow parsers.
call_rainbow( path, format_in = c("agilent_d", "waters_raw", "masshunter", "chemstation", "chemstation_uv", "chemstation_fid", "chemstation_ms"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), by = c("detector", "name"), what = NULL, read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, precision = 1, sparse = TRUE, bin_width = NULL, centroid = FALSE, hrms = FALSE )call_rainbow( path, format_in = c("agilent_d", "waters_raw", "masshunter", "chemstation", "chemstation_uv", "chemstation_fid", "chemstation_ms"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), by = c("detector", "name"), what = NULL, read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, precision = 1, sparse = TRUE, bin_width = NULL, centroid = FALSE, hrms = FALSE )
path |
Path to file. |
format_in |
Format of the supplied files. Either |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
by |
How to group the returned list: by |
what |
Which detectors to return (e.g. |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
precision |
Number of decimals of the m/z grid, which is spaced
|
sparse |
Logical. Whether to drop zero intensities from MS data.
Applies only to |
bin_width |
Width of the m/z grid, in daltons. An alternative to
|
centroid, hrms
|
Logical. Whether to read the centroided ( |
Uses rainbow parsers to read in Agilent
(.D) and Waters (.raw) files. For agilent_d, waters_raw and
masshunter, path is the data directory (.D or .raw), and the result
is a list grouped according to by. For the chemstation formats, path
is a single file (e.g. .uv), the result is a single chromatogram, and by
and what are ignored. Otherwise, data can be filtered by detector type
using the what argument.
A (nested) list of chromatograms, or a single chromatogram for the
chemstation formats, in the class given by format_out. The list is
grouped according to the value of by.
Ethan Bass
Other external parsers:
call_entab(),
call_openchrom(),
read_thermoraw(),
sp_converter(),
uv_converter()
## Not run: call_rainbow("path/to/file.D", format_in = "agilent_d") ## End(Not run)## Not run: call_rainbow("path/to/file.D", format_in = "agilent_d") ## End(Not run)
Configures OpenChrom to use command-line interface. Requires OpenChrom version prior to 1.5.0.
configure_openchrom(cli = c("null", "true", "false", "status"), path = NULL)configure_openchrom(cli = c("null", "true", "false", "status"), path = NULL)
cli |
One of |
path |
Path to the 'OpenChrom' executable (optional). The supplied path is saved and used in later calls. |
If cli is "status", the string "true" or "false", saying
whether the command-line interface is enabled. Otherwise, the path to the
OpenChrom command-line application.
Ethan Bass
## Not run: configure_openchrom(cli = "status") ## End(Not run)## Not run: configure_openchrom(cli = "status") ## End(Not run)
Extract metadata as a data.frame, data.table or tibble from a list of
chromatograms.
extract_metadata( chrom_list, what = chrom_metadata_fields(), detector = NULL, format_out = c("data.frame", "data.table", "tibble"), collapse = FALSE, expand = FALSE, by = c("sample", "chromatogram"), digits = NULL )extract_metadata( chrom_list, what = chrom_metadata_fields(), detector = NULL, format_out = c("data.frame", "data.table", "tibble"), collapse = FALSE, expand = FALSE, by = c("sample", "chromatogram"), digits = NULL )
chrom_list |
A list of chromatograms with attached metadata (as returned
by |
what |
A character vector specifying the metadata elements to
extract. Defaults to every field chromConverter attaches; no format
records all of them, so the elements a format does not provide are
absent from the result. Superseded names (e.g. |
detector |
A character vector of detectors to include (e.g. |
format_out |
Format of object. Either |
collapse |
Logical. Whether to collapse a field holding more than one
value ( |
expand |
Whether to include the nested metadata fields, whose value is
itself a list or table rather than a single value per chromatogram: the
|
by |
Whether to return one row per |
digits |
Number of significant digits for the numbers in a field
collapsed into a string (see |
A data.frame, tibble, or data.table (according to the value of
format_out), with one row per sample or chromatogram (see by) and the
specified metadata elements as columns, or NA if none of the specified
elements could be found. For a list, the first column, name, identifies
each row: by the sample's name, or with by = "chromatogram" by the
chromatogram's path through the list (e.g. blue.UV).
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) extract_metadata(chroms, what = c("sample_name", "run_datetime", "time_range"))path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) extract_metadata(chroms, what = c("sample_name", "run_datetime", "time_range"))
Extracts the same element from every sample of a chrom_list whose samples
are themselves lists, such as the output of read_chroms with several
what values (e.g. c("dad", "instrument")). The result has one
chromatogram per sample, which packages that expect a list of chromatograms,
such as chromatographR, accept as is.
get_element(x, what)get_element(x, what)
x |
A |
what |
The element to extract: a single name (e.g. |
A list of the extracted chromatograms, with the names and class of
x.
path <- system.file("extdata", "benzoxazinoid_standards", "BENZOS_250PPM.D", package = "chromConverter") run <- read_chroms(path, format_in = "agilent_d", what = c("chroms", "instrument"), progress_bar = FALSE) pressure <- get_element(run, "instrument:PMP1, Pressure") head(pressure[[1]])path <- system.file("extdata", "benzoxazinoid_standards", "BENZOS_250PPM.D", package = "chromConverter") run <- read_chroms(path, format_in = "agilent_d", what = c("chroms", "instrument"), progress_bar = FALSE) pressure <- get_element(run, "instrument:PMP1, Pressure") head(pressure[[1]])
Prints a summary of a chrom_list without displaying the underlying
chromatographic data. Attributes that are constant across all chromatograms
are collapsed into a single header line, while varying attributes are shown
as a table truncated to the first n rows. When a sample holds more than
one chromatogram, its traces are printed as a block headed by the sample,
and any attribute they all share is shown in that block's header rather
than repeated down it.
## S3 method for class 'chrom_list' print( x, n = 10, cols = chrom_summary_cols(), digits = getOption("digits"), ... )## S3 method for class 'chrom_list' print( x, n = 10, cols = chrom_summary_cols(), digits = getOption("digits"), ... )
x |
A |
n |
Integer. Maximum number of chromatograms to show in the table.
Defaults to |
cols |
Character vector of attribute names to report. Defaults to:
|
digits |
Number of significant digits for numeric metadata. Defaults
to |
... |
Additional arguments (currently ignored). |
Invisibly returns x.
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) print(chroms)path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) print(chroms)
Extracts injection metadata from 'Agilent Common Analytical Markup Language' (ACAML) files into a table.
read_acaml( path, find_files, format_out = c("data.frame", "data.table", "tibble"), progress_bar = FALSE, cl = 1 )read_acaml( path, find_files, format_out = c("data.frame", "data.table", "tibble"), progress_bar = FALSE, cl = 1 )
path |
Path(s) to ACAML files or to folders that contain the files. |
find_files |
Logical. Whether to treat the supplied paths as directories to search for files. Inferred if not supplied, by testing whether every path is a file. |
format_out |
Class of output. Either |
progress_bar |
Logical. Whether to show a progress bar. Defaults to
|
cl |
Argument to pbapply specifying the number of
parallel workers to use or a cluster object created by
makeCluster (a set of parallel R worker processes).
Defaults to |
ACAML is an XML-based format used by Agilent OpenLab to store sequence and
sample metadata. This function extracts information from the
InjectionMetaData nodes embedded in the InjectionMetaDataItems
custom field files, which do not seem to be readily accessible through other
means.
A data.frame, data.table or tibble (according to the value of
format_out) with one row per injection, and a SourceFile column naming
the ACAML file it came from.
## Not run: read_acaml(path) ## End(Not run)## Not run: read_acaml(path) ## End(Not run)
Parses an Agilent .amx method archive, extracting instrument parameters
from one or more of its driver sub-files.
read_agilent_amx( path, what = c("dad", "pump", "comp", "sampler"), path_out = NULL, format_out = c("data.frame", "tibble", "data.table"), gradient_format = c("wide", "long") )read_agilent_amx( path, what = c("dad", "pump", "comp", "sampler"), path_out = NULL, format_out = c("data.frame", "tibble", "data.table"), gradient_format = c("wide", "long") )
path |
Path to the |
what |
One or more instrument modules to parse. Any
combination of |
path_out |
Directory into which the archive
is extracted. If |
format_out |
Class of the |
gradient_format |
Whether to return the gradient in |
A named list with one element per parsed module, plus "metadata".
A module the archive has no driver file for is left out with a warning,
and it is an error if none of the requested modules has one. The comp module is returned as column and
sampler as autosampler. See below for the structure of each.
metadata — a list with scalar elements:
method_nameOriginal method name.
versionMethod version string.
statusApproval state.
createdCreation timestamp (POSIXct, UTC).
created_byUsername of creator.
modifiedLast-modified timestamp (POSIXct, UTC).
modified_byUsername of last modifier.
pump — a list with scalar elements flow_mL_min, stop_time_min,
post_time_min, pressure_low_bar, pressure_high_bar, plus:
solventsA table of active solvent channels: channel (e.g.
"A"), percentage and solvent (its name, or NA).
gradientA table of timetable entries. Wide format (default):
time_min plus one pct_<channel> column per active channel, and a
flow_mL_min column if the timetable changes the flow. Long format:
time_min, channel, percent, where a flow channel holds the
flow in mL/min.
dad — a list with scalar elements peakwidth_code, slitwidth_nm,
uv_lamp_required, vis_lamp_required, spectra_from_nm,
spectra_to_nm, spectra_step_nm, plus:
signalsA table of active signals: id (e.g. "A"),
wavelength_nm, bandwidth_nm, reference_nm and
reference_bandwidth_nm (NA without a reference).
peakwidth_code is the stored code for the detector's peak width
setting, which sets its data rate and response time; for example, 4 is
"> 0.1 min". It is not decoded, since detector models offer different
settings.
column — a list with scalar element post_time_min, plus:
temp_controlsTwo-row table (Left/Right): side,
temperature_C, not_ready_limit_C, equilibration_time_min.
autosampler — a list with scalar elements: thermostat_installed,
draw_speed_uL_min, eject_speed_uL_min,
wait_after_draw_min, injection_volume_uL, wash_time_s.
## Not run: read_agilent_amx(path) ## End(Not run)## Not run: read_agilent_amx(path) ## End(Not run)
Reads the .ch, .uv, Report.TXT (or Result.xml) and LCDIAG.REG
files in an 'Agilent' .D directory. Other files in the directory are
ignored.
read_agilent_d( path, what = c("dad", "chroms", "peak_table", "MS1", "MS2", "TIC", "BPC"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )read_agilent_d( path, what = c("dad", "chroms", "peak_table", "MS1", "MS2", "TIC", "BPC"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )
path |
Path to 'Agilent' |
what |
Whether to extract chromatograms ( |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
Instrument traces are named from LCDIAG.REG, so the names differ between
'ChemStation' revisions and/or instruments (e.g. "PMP1, Pressure" and
"PMP1, PMP1A, Pressure"). Parts of the file that cannot be read are skipped
with a warning.
Mass spectra are read from the AcqData folder of a 'MassHunter' .d
directory. Its MSScan.bin and MSScan.xsd describe every scan, as in
read_agilent_dx, and the spectra are in MSPeak.bin, or in
MSProfile.bin for profiles. Each profile starts with its first m/z and the step between points, as
two doubles or two 32-bit floats, followed by the intensities as 32-bit
floats or integers respectively. The points are spaced by the scan's
SamplingPeriod rather than the stored step, which can be slightly smaller.
Spectra can be read only from unit-resolution instruments, such as single
quadrupole GC-MS and LC-MS, and triple quadrupole LC-MS. MS1 holds the
scans at MS level 1 and MS2 the product ion and MRM scans, each with the
m/z it selected in the first quadrupole as precursor_mz. Neutral loss and precursor ion scans
are skipped with a warning. The TIC and BPC come from the record of
every scan, so they are also returned for runs whose spectra cannot be read.
For high-resolution spectra, try parser = "rainbow" with centroid or
hrms.
A list with one element per type found, each a chromatogram or a
list of them named by file, in the format specified by format_out and
data_format. If data_format is wide, the chromatograms will be
returned with retention times as rows and columns containing signal intensity
for each signal. If long format is requested, retention times will be
in the first column. The format_out argument determines whether the
chromatogram is returned as a matrix, data.frame or data.table.
Peak tables are returned in the chromatographr layout described in
read_peaklist, named by wavelength (e.g. "254"), and keep the report's
name for the signal as signal_descriptor. They are read from Result.xml
where the directory has one, since unlike Report.TXT it records where each
peak starts and ends. Mass spectra and the BPC are always in long format,
with rt, mz and intensity columns, and a precursor_mz column before
mz for MS2. They are returned as a data.table when format_out is
matrix. Each table of spectra has a scan_info attribute with one row per
scan, giving its scan, rt, ms_level, polarity and scan_type
("scan", "SIM", "MRM" or "product ion scan", and NA for any other
type), and for MS2 its
precursor_mz and collision_energy.
Metadata are attached as attributes if read_metadata is TRUE. With collapse = TRUE, a list of one element is replaced by that
element.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
path <- system.file("extdata", "benzoxazinoid_standards", "BENZOS_250PPM.D", package = "chromConverter") run <- read_agilent_d(path) names(run$chroms) pump <- read_agilent_d(path, what = "instrument") names(pump)path <- system.file("extdata", "benzoxazinoid_standards", "BENZOS_250PPM.D", package = "chromConverter") run <- read_agilent_d(path) names(run$chroms) pump <- read_agilent_d(path, what = "instrument") names(pump)
Reads 'Agilent' .dx files.
read_agilent_dx( path, what = c("chroms", "dad"), path_out = NULL, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )read_agilent_dx( path, what = c("chroms", "dad"), path_out = NULL, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )
path |
Path to Agilent |
what |
Whether to extract chromatograms ( |
path_out |
A directory to export unzipped files. If a path is not
specified, a temporary directory is used. The files are extracted into a
folder named for |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
The archive is extracted to path_out, or to a temporary directory that is
deleted afterwards, and its .ch, .uv and .it files are read with
read_chemstation_ch, read_chemstation_uv and an internal reader for
.it files.
The mass spectra of an MS injection are not in the archive. They are in the
.MSScan.bin and .MSPeak.bin files of the same name beside it. The first
is needed for MS1, TIC and BPC, the second for MS1. MSScan.bin holds one
record per scan, laid out as the archive's MSData/MSScan.xsd describes,
which gives the retention time, TIC and base peak of the scan and the
location of its spectrum in MSPeak.bin. Each spectrum there is the scan's
m/z values followed by as many intensities, as 32- or 64-bit floats or
32-bit integers depending on the scan's spectrum format and size. Only scans
at MS level 1 are read into MS1, while the TIC and BPC cover every
scan.
Where the archive holds an injection.acmd file, the run_datetime and
sample_injection_volume attributes are taken from it. Its run time
records the offset from UTC, while the .ch and .uv headers give only
the local time.
A list with one element per type in what, each a chromatogram or
a list of chromatograms named by signal, in the format specified by
format_out and data_format. Mass spectra and the BPC are always in
long format, with rt, mz and intensity columns, and are returned as a
data.table when format_out is matrix. With collapse = TRUE, a list of one
element is replaced by that element.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
## Not run: read_agilent_dx(path) ## End(Not run)## Not run: read_agilent_dx(path) ## End(Not run)
Reads a sequence of injections from an 'Agilent' .rslt directory.
Combines raw chromatogram data from .dx files with injection-level
metadata parsed from the accompanying .acaml file.
read_agilent_rslt( path, what = c("chroms", "dad"), path_out = NULL, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, sample_names = c("basename", "sample_name"), progress_bar = FALSE, cl = 1 )read_agilent_rslt( path, what = c("chroms", "dad"), path_out = NULL, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, sample_names = c("basename", "sample_name"), progress_bar = FALSE, cl = 1 )
path |
Path to 'Agilent' |
what |
Whether to extract chromatograms ( |
path_out |
A directory to export unzipped files. If a path is not
specified, a temporary directory is used. The files are extracted into a
folder named for |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
sample_names |
How to name the chromatograms that are returned. Either
|
progress_bar |
Logical. Whether to show a progress bar while reading
the sequence's |
cl |
Argument to pbapply specifying the number
of clusters to use or a cluster object created by
makeCluster. Defaults to |
Currently this function only reads .dx chromatogram files. To read the
peak tables stored in .rx files, use read_peaklist with
format_in = "openlab".
A list of chromatograms (one read_agilent_dx-style result per
injection in the sequence), in the format specified by data_format and
format_out. If read_metadata is TRUE, injection-level metadata parsed
from the .acaml file is attached to each chromatogram as attributes.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
## Not run: read_agilent_rslt("path/to/sequence.rslt") ## End(Not run)## Not run: read_agilent_rslt("path/to/sequence.rslt") ## End(Not run)
Reads chromatograms, mass spectra and peak lists from 'Allotrope Simple Model' chromatography files into R.
read_asm( path, what = c("chroms", "MS1"), data_format = c("wide", "long"), format_out = c("matrix", "data.frame", "data.table"), peaktable_format = c("chromatographr", "original"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )read_asm( path, what = c("chroms", "MS1"), data_format = c("wide", "long"), format_out = c("matrix", "data.frame", "data.table"), peaktable_format = c("chromatographr", "original"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )
path |
Path to ASM |
what |
What to read: 2D chromatograms ( |
data_format |
Whether to return data in |
format_out |
Class of output. Either |
peaktable_format |
Whether to return peak tables in the standard
|
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
Retention times in seconds are converted to minutes. Other units, such as
retention volumes (mL), are returned as the file declares them. The unit is
recorded in the time_unit attribute.
A file can hold several injections, such as a sequence exported from a chromatography data system. Each injection is then returned as a separate sample, named by its sample name, and read_chroms adds each one to the list of samples it returns.
Mass spectra have so far only been tested against the example files published by the Allotrope Foundation.
A 2D chromatogram in the format specified by format_out and
data_format, or a list of them named by detection type if the file holds
more than one (or collapse = FALSE). Mass spectra are returned as a
data.frame (or data.table) with columns rt, mz and intensity, and
peak tables as a data.frame (or data.table) per measurement. Instrument
traces are returned as 2D chromatograms named by trace. Where more
than one of these is returned, they are combined in a list named by what.
A file with several injections returns a chrom_list with one such
element per injection. Metadata are attached as attributes if
read_metadata is TRUE.
Ethan Bass
## Not run: read_asm("path/to/file.json") read_asm("path/to/file.json", what = "peak_table") ## End(Not run)## Not run: read_asm("path/to/file.json") read_asm("path/to/file.json", what = "peak_table") ## End(Not run)
Reads 'Analytical Data Interchange' (ANDI) netCDF (.cdf) files.
read_cdf( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), what = NULL, read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, peaktable_format = c("chromatographr", "original"), ... )read_cdf( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), what = NULL, read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, peaktable_format = c("chromatographr", "original"), ... )
path |
Path to ANDI netCDF file. |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
what |
For ANDI chrom files, |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
peaktable_format |
Whether to return peak tables in the standard
|
... |
Additional arguments to the parser. For ANDI MS files, pass
|
Retention times are returned in minutes, converted from the unit the file
declares. An ANDI chrom file declares it in its retention_unit attribute,
which also governs the peak table. Seconds is both what the template uses
and what all but one of its conformance files declare, so a file that
declares no unit is read as seconds, unless chromConverter wrote it, in
which case it is read as minutes.
An ANDI MS file has no mandatory unit attribute, since the specification
never formally defined its axes units, so scan_acquisition_time is read as
seconds, the only unit the specification suggests, unless a
raw_data_time_units attribute says otherwise.
Either kind of file warns about a unit it does not recognize and reads it as seconds.
Some writers that do not record peak heights fill peak_height with -1
or 0 for every peak. A chromatographr peak table returns NA heights
in these cases.
A chromatogram in the format specified by the format_out and
data_format arguments.
Ethan Bass
## Not run: read_cdf("path/to/file.cdf") ## End(Not run)## Not run: read_cdf("path/to/file.cdf") ## End(Not run)
Reads 'Agilent ChemStation' .ch files.
read_chemstation_ch( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), scale = TRUE, source_file = NULL )read_chemstation_ch( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), scale = TRUE, source_file = NULL )
path |
Path to 'Agilent' |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
scale |
Whether to multiply the data by the file's scaling factor and
add its intercept. Defaults to |
source_file |
Source file from which chromatogram data was originally derived. |
'Agilent' .ch files come in several formats. This parser detects the
version from the file and reads versions 8, 30, 130, 81, 179 and
181 from 'Agilent ChemStation' and 'Agilent OpenLab'; any other version is
an error. Versions 30 and 130 are generally produced by ultraviolet
detectors, and 81, 179 and 181 by flame ionization detectors (FID).
A 2D chromatogram in the format specified by data_format and
format_out. If data_format is wide, the chromatogram will be returned
with retention times as row names and a single column for the intensity. If
long format is requested, two columns will be returned: one for the
retention time and one for the intensity. The format_out argument
determines whether the chromatogram is returned as a matrix, data.frame,
or data.table. Metadata are attached to the chromatogram as attributes
if read_metadata is TRUE.
This function was adapted from the Chromatography Toolbox (© James Dillon 2014).
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
read_chemstation_ch("tests/testthat/testdata/chemstation_130.ch")read_chemstation_ch("tests/testthat/testdata/chemstation_130.ch")
Reads 'Agilent ChemStation' .csv files.
read_chemstation_csv( path, format_out = "matrix", data_format = "wide", read_metadata = TRUE )read_chemstation_csv( path, format_out = "matrix", data_format = "wide", read_metadata = TRUE )
path |
Path to 'Agilent' |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to
|
'Agilent ChemStation' CSV files are encoded in UTF-16.
A chromatogram in the format specified by format_out and
data_format.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
read_chemstation_csv("tests/testthat/testdata/dad1.csv")read_chemstation_csv("tests/testthat/testdata/dad1.csv")
Reads the event log 'Agilent ChemStation' writes to the folder of each
sequence, or the RUN.LOG it writes to each .D folder when that file is
named in paths. These record instrument errors, aborted runs and routine
readings such as pump pressure and column temperature.
read_chemstation_logs( paths, what = c("injections", "problems", "events"), format_out = "data.frame" )read_chemstation_logs( paths, what = c("injections", "problems", "events"), format_out = "data.frame" )
paths |
Paths to 'ChemStation' |
what |
What to return: one row per injection ( |
format_out |
Class of the returned object: |
Directories in paths are searched, including their subdirectories, for
sequence logs: every .LOG file outside a .D folder. RUN.LOG files are
left out, since the sequence log holds their events. A file found this way
that is not a 'ChemStation' log is skipped with a warning; a file named in
paths that is not one is an error.
Tested on logs from 'ChemStation' revisions A.10.02, B.01.03 and B.04.02.
A data.frame or data.table. For injections, one row per
injection, with columns:
sequence: the name of the 'ChemStation' sequence, taken from the log's
own sequence events or, failing those, from the name of the file. NA for
a RUN.LOG, which has neither.
folder: the folder the sequence's data are in, which can differ from
sequence. This is the folder holding the log, or for a RUN.LOG the
folder holding its .D folder.
injection: numbers the injections in the order the log starts them.
data_file: the .D folder the log names for the injection. The log
records it only once the run's data are analyzed, so an aborted injection
has none, and its case can differ from the folder on disk.
sample: the sample, as the log names it.
start: POSIXct, UTC. The run_datetime of the traces and reports in a
.D folder is instead the instrument's local time labeled as UTC, so match
injections to them by data_file rather than by time.
minutes: from the injection's first event to its last.
status: completed, aborted, stopped by user or incomplete.
pressure_start, pressure_end: the first and last reading of pump 1, in
bar.
problems: the injection's problem messages, separated by "; ".
For events, one row per event, with sequence, folder, injection and
data_file as above, and:
time: POSIXct, UTC, as recorded in the event's header. The local time
printed in the log's text is not returned.
problem: whether the event reports an alarm from an instrument module
(any event from a module with a non-zero event_code, such as a leak or a
shutdown), a method that was aborted, timed out, stopped by an instrument
error or stopped by the user, or a sequence that was terminated or
stopped.
event_code, module_id: hexadecimal strings, since 'Agilent' does not
document them. The same module always carries the same module_id (for
example, 1da6 for the pump in 'Agilent 1100' logs).
source: e.g. "1100 PMP 1", "Method" or "Sequence".
message: the event's text. The log splits a message longer than 45
characters over several events, which are joined, but stores a message of
exactly 45 characters without its last character.
Events of the sequence itself, events between injections such as loading
the next method, and method runs that acquire no data, such as a
data-analysis-only re-run of the sequence, have no injection or
data_file.
For problems, the events marked as a problem, without that column and
with incident, which numbers the runs of problem events in the same log
that are less than a minute apart, such as a leak and the shutdowns that
follow it.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
read_chemstation_logs("tests/testthat/testdata/chemstation_sequence.LOG") read_chemstation_logs("path/to/sequences", what = "problems")read_chemstation_logs("tests/testthat/testdata/chemstation_sequence.LOG") read_chemstation_logs("path/to/sequences", what = "problems")
Reads the pump, diode array detector, autosampler and column thermostat
settings from the module register files (LPMP1.REG, LDAD1.REG,
LALS1.REG or LWLS1.REG, and LTHM1.REG) of a 'ChemStation' .M method
directory. Revisions that store a module's settings as 'RapidControl' XML
(e.g. AgilentPumpDriver1.RapidControl.MethodXML.xml) instead are read as
'OpenLab CDS' methods are by read_agilent_amx.
read_chemstation_method( path, what = c("pump", "dad", "sampler", "column"), format_out = c("data.frame", "tibble", "data.table"), gradient_format = c("wide", "long") )read_chemstation_method( path, what = c("pump", "dad", "sampler", "column"), format_out = c("data.frame", "tibble", "data.table"), gradient_format = c("wide", "long") )
path |
Path to a |
what |
One or more instrument modules to read: any combination of
|
format_out |
Class of the |
gradient_format |
Whether to return the gradient in |
Depending on how 'ChemStation' is configured, a .D directory may hold a
copy of the method it was acquired with, in ACQ.M or, in older revisions,
RUN.M. path can then be the .D directory itself. Its DA.M holds the
data analysis method instead, whose pump settings may not be those the run
was acquired with; reading it gives a warning.
The gradient follows the pump's timetable, with each parameter changing linearly between the times it is set. Channel A is the pump's primary channel and delivers whatever the other channels leave, so it is always included and its share is computed rather than read.
A named list with one element per module read. A module the method
has no settings for is left out with a warning, and it is an error if
none of the requested modules are present. The sampler module is
returned as autosampler. The elements are those of read_agilent_amx,
with NA for a setting the method does not record:
pump: a list with scalar elements flow_mL_min, stop_time_min,
post_time_min, pressure_low_bar and pressure_high_bar, plus:
solvents: a table of the channels in use, with columns channel,
percentage (at the start of the run) and solvent (the name entered
for it, or NA).
gradient: the timetable. Wide format: time_min and a pct_<channel>
column per channel in use, plus flow_mL_min if the timetable sets the
flow. Long format: time_min, channel and percent, where a flow
channel holds the flow in mL/min. An empty timetable gives the starting
composition at time 0.
dad: a list with scalar elements peakwidth_code, slitwidth_nm,
uv_lamp_required, vis_lamp_required, spectra_from_nm,
spectra_to_nm and spectra_step_nm, plus
signals, a table of the stored signals with columns id,
wavelength_nm, bandwidth_nm, reference_nm and
reference_bandwidth_nm (NA without a reference).
peakwidth_code is the stored code for the detector's peak width
setting, which sets its data rate and response time; for example, 4 is
"> 0.1 min". It is not decoded, since detector models offer different
settings.
autosampler: a list with scalar elements thermostat_installed,
draw_speed_uL_min, eject_speed_uL_min, wait_after_draw_min,
injection_volume_uL and wash_time_s. Register files record only the
speeds and the injection volume.
column: a list with scalar element post_time_min (NA when off),
plus temp_controls, a two-row table (Left, Right) with columns
side, temperature_C, not_ready_limit_C and equilibration_time_min.
A temperature stored below absolute zero (e.g. -274) is NA; this may
mean no temperature was set.
Ethan Bass
read_agilent_amx for 'OpenLab CDS' methods, and read_agilent_d
with what = "instrument" for the pump's record of what it delivered.
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_ms(),
read_chemstation_reports(),
read_chemstation_uv()
## Not run: method <- read_chemstation_method("path/to/METHOD.M") method$pump$gradient ## End(Not run)## Not run: method <- read_chemstation_method("path/to/METHOD.M") method$pump$gradient ## End(Not run)
Reads 'Agilent ChemStation MSD Spectral Files' beginning with
x01/x32/x00/x00.
read_chemstation_ms( path, what = c("MS1", "BPC", "TIC"), format_out = c("matrix", "data.frame", "data.table"), data_format = "long", read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )read_chemstation_ms( path, what = c("MS1", "BPC", "TIC"), format_out = c("matrix", "data.frame", "data.table"), data_format = "long", read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )
path |
Path to 'Agilent' |
what |
Which streams to return: |
format_out |
Class of output. Either |
data_format |
Whether to return the |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
A list of the streams in what, in the format specified by
format_out. In wide format, the BPC and TIC have retention times as
rows and a single intensity column; in long format, a retention time column
and an intensity column. MS data will always be returned in long format. The
format_out argument determines whether the chromatogram is returned as a
matrix, data.frame, or data.table. Metadata are attached as attributes if
read_metadata is TRUE. With collapse = TRUE, a list of one stream is
replaced by that stream.
Many thanks to Evan Shi and Eugene Kwan for providing helpful information on the structure of these files in the rainbow documentation.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_reports(),
read_chemstation_uv()
## Not run: read_chemstation_ms(path) ## End(Not run)## Not run: read_chemstation_ms(path) ## End(Not run)
Reads peak tables from 'Agilent ChemStation' Report.TXT files, or from the
Result.xml files 'ChemStation' writes when set up to export its results.
Only Result.xml records where each peak starts and ends, so it is read in
preference to a Report.TXT in the same directory.
read_chemstation_reports( paths, peaktable_format = c("chromatographr", "original"), metadata_format = c("chromconverter", "raw"), data_format = NULL )read_chemstation_reports( paths, peaktable_format = c("chromatographr", "original"), metadata_format = c("chromconverter", "raw"), data_format = NULL )
paths |
Paths to 'ChemStation' |
peaktable_format |
Whether to return peak tables in the standard
|
metadata_format |
Format to output metadata. Either |
data_format |
Deprecated. Use |
A peak_list: a list with one element per report, named by its
.D directory, each holding one peak table per signal, named by
wavelength.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_uv()
path <- system.file("extdata", "benzoxazinoid_standards", "BENZOS_250PPM.D", "Report.TXT", package = "chromConverter") read_chemstation_reports(path)path <- system.file("extdata", "benzoxazinoid_standards", "BENZOS_250PPM.D", "Report.TXT", package = "chromConverter") read_chemstation_reports(path)
Agilent .uv files come in several formats. This parser detects the
version from the file and reads versions 31 and 131 from 'Agilent
ChemStation' and 'Agilent OpenLab'; any other version is an error.
read_chemstation_uv( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), scale = TRUE, source_file = NULL )read_chemstation_uv( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), scale = TRUE, source_file = NULL )
path |
Path to 'Agilent' |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
scale |
Whether to scale the data by the scaling factor present in the
file. Defaults to |
source_file |
Source file from which UV data was originally derived. |
Retention times are read from each spectrum, so they are unevenly spaced when the detector did not store every spectrum. Interpolate onto a common time axis before comparing runs.
A 3D chromatogram in the format specified by data_format and
format_out. If data_format is wide, the chromatogram will
be returned with retention times as row names and wavelengths as columns. If
long format is requested, three columns will be returned: one for the
retention time, one for the wavelength and one for the intensity. The
format_out argument determines whether the chromatogram is returned as
a matrix, data.frame, or data.table. Metadata are attached to the
chromatogram as attributes if read_metadata is TRUE.
This function was adapted from the parser in the rainbow project licensed under GPL 3 by Evan Shi https://rainbow-api.readthedocs.io/en/latest/agilent/uv.html.
Ethan Bass
Other 'Agilent' parsers:
read_agilent_d(),
read_agilent_dx(),
read_agilent_rslt(),
read_chemstation_ch(),
read_chemstation_csv(),
read_chemstation_logs(),
read_chemstation_method(),
read_chemstation_ms(),
read_chemstation_reports()
read_chemstation_uv("tests/testthat/testdata/dad1.uv")read_chemstation_uv("tests/testthat/testdata/dad1.uv")
Reads 'Chromatotec' .Chrom files.
read_chromatotec( path, what = c("chrom", "peak_table"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, peaktable_format = c("chromatographr", "original") )read_chromatotec( path, what = c("chrom", "peak_table"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, peaktable_format = c("chromatographr", "original") )
path |
The path to 'Chromatotec' |
what |
Whether to extract chromatograms ( |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
peaktable_format |
Whether to return peak tables in the standard
|
A chromatogram and/or peak table from the specified path, according
to the value of what, with times in minutes. Chromatograms are returned in
the format specified by format_out. The rows of the peak table that
report a total over most of the run rather than a peak, such as
NMTHC-EqC6 and THC_PAMS, are only kept with
peaktable_format = "original". In the original table, Start and End
are where integration of the peak starts and ends, and SubstanceIndex
appears to be the position of its substance in the run's substance table
(0 for an unnamed peak); U1, U3 and U4 have not been identified.
Ethan Bass
## Not run: read_chromatotec(path) ## End(Not run)## Not run: read_chromatotec(path) ## End(Not run)
Reads 'Thermo Fisher Chromeleon™ CDS' ASCII (.txt) files.
read_chromeleon( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), decimal_mark = NULL )read_chromeleon( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), decimal_mark = NULL )
path |
Path to 'Chromeleon' ASCII file. |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
decimal_mark |
Which character is used as the decimal separator in the
file. By default, decimal mark will be detected automatically, but it can
also be manually set as |
A chromatogram in the format specified by format_out (retention
time x wavelength).
Ethan Bass
## Not run: read_chromeleon("path/to/file.txt") ## End(Not run)## Not run: read_chromeleon("path/to/file.txt") ## End(Not run)
Reads chromatograms from specified folders or vector of paths using either an internal parser or bindings to an external library, such as Aston, Entab, ThermoRawFileParser, OpenChrom, rainbow.
read_chroms( paths, format_in = supported_formats(), find_files, pattern = NULL, parser = c("", "chromconverter", "aston", "entab", "thermoraw", "openchrom", "rainbow"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), path_out = NULL, export_format = c("", "csv", "chemstation_csv", "cdf", "mzml", "animl", "arw"), force = FALSE, read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), progress_bar, cl = 1, verbose = getOption("verbose"), sample_names = c("basename", "sample_name"), sort_by = c("auto", "none", "acquisition_time", "file_time"), dat = NULL, ... )read_chroms( paths, format_in = supported_formats(), find_files, pattern = NULL, parser = c("", "chromconverter", "aston", "entab", "thermoraw", "openchrom", "rainbow"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), path_out = NULL, export_format = c("", "csv", "chemstation_csv", "cdf", "mzml", "animl", "arw"), force = FALSE, read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), progress_bar, cl = 1, verbose = getOption("verbose"), sample_names = c("basename", "sample_name"), sort_by = c("auto", "none", "acquisition_time", "file_time"), dat = NULL, ... )
paths |
Paths to data files or directories containing the files. |
format_in |
Format of the files to be imported or converted. One of:
|
find_files |
Logical. Whether to treat |
pattern |
Regular expression that file names must match (e.g. a file
extension). Defaults to |
parser |
What parser to use (optional). Current options are
|
format_out |
Class of output. Either |
data_format |
Whether to output data in wide or long format. Either
|
path_out |
Path for exporting files. If it is not specified, the user
is asked whether to export to a |
export_format |
Export format: |
force |
Logical. Whether to overwrite files when exporting. Defaults to
|
read_metadata |
Logical, whether to attach metadata (if it's available).
Defaults to |
metadata_format |
Format to output metadata. Either |
progress_bar |
Logical. Whether to show progress bar. Defaults to |
cl |
Argument to pbapply specifying the number
of parallel workers to use or a cluster object created by
makeCluster. Defaults to |
verbose |
Logical. Whether to print status messages, and the output of external parsers, to the R console. |
sample_names |
Which sample names to use. Options are |
sort_by |
How to sort the chromatograms: |
dat |
Deprecated. Existing list of chromatograms to append results
to. Use |
... |
Additional arguments to the parser. Where the parser does not
take |
Provides a unified interface to all chromConverter parsers. The formats it
recognizes are listed under the format_in argument. It also wraps the
'OpenChrom' parsers, which cover many additional formats but require
'OpenChrom' 1.4 or earlier (see call_openchrom). The 'Entab',
'ThermoRawFileParser' and 'OpenChrom' parsers must be installed separately;
see the instructions in the
README.
If paths to individual files are provided, read_chroms infers the file
format from the first file and selects a parser for it. When providing
paths to directories, the file format must be specified using the
format_in argument.
A chrom_list of chromatograms in matrix, data.frame, or
data.table format, according to the value of format_out. Chromatograms
may be returned in either wide or long format according to the value of
data_format. Peak tables are returned in the chromatographr layout
described in read_peaklist, which can also return all the columns the
file provides.
If export_format is provided, chromatograms are
written to the folder given by path_out in that format. The options are
csv, chemstation_csv, cdf, mzml and arw, as well as animl
(AnIML) when an openchrom parser is selected. Files are also
written to path_out whenever the thermoraw or openchrom parser is
used, as these parsers convert the files before reading them: thermoraw
to mzML, and openchrom to export_format (mzml by default).
Ethan Bass
path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") chroms <- read_chroms(path, format_in = "shimadzu_ascii", find_files = FALSE, progress_bar = FALSE)path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") chroms <- read_chroms(path, format_in = "shimadzu_ascii", find_files = FALSE, progress_bar = FALSE)
Reads 'Lumex' .mdf files.
read_mdf( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE )read_mdf( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE )
path |
The path to a 'Lumex' |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
A chromatogram in the format specified by the format_out and
data_format arguments.
Ethan Bass
## Not run: read_mdf("path/to/file.mdf") ## End(Not run)## Not run: read_mdf("path/to/file.mdf") ## End(Not run)
Reads the metadata of chromatogram files into a table, without returning
the chromatograms. It takes the same paths and formats as read_chroms and
gives the table that extract_metadata would give for the chromatograms
read_chroms returns.
read_metadata( paths, format_in = supported_formats(), find_files, pattern = NULL, parser = c("", "chromconverter", "aston", "entab", "thermoraw", "openchrom", "rainbow"), what = chrom_metadata_fields(), format_out = c("data.frame", "data.table", "tibble"), metadata_format = c("chromconverter", "raw"), collapse = FALSE, expand = FALSE, digits = NULL, progress_bar, cl = 1, verbose = getOption("verbose"), sample_names = c("basename", "sample_name"), sort_by = c("auto", "none", "acquisition_time", "file_time"), ... )read_metadata( paths, format_in = supported_formats(), find_files, pattern = NULL, parser = c("", "chromconverter", "aston", "entab", "thermoraw", "openchrom", "rainbow"), what = chrom_metadata_fields(), format_out = c("data.frame", "data.table", "tibble"), metadata_format = c("chromconverter", "raw"), collapse = FALSE, expand = FALSE, digits = NULL, progress_bar, cl = 1, verbose = getOption("verbose"), sample_names = c("basename", "sample_name"), sort_by = c("auto", "none", "acquisition_time", "file_time"), ... )
paths |
Paths to data files or directories containing the files. |
format_in |
Format of the files to be imported or converted. One of:
|
find_files |
Logical. Whether to treat |
pattern |
Regular expression that file names must match (e.g. a file
extension). Defaults to |
parser |
What parser to use (optional). Current options are
|
what |
A character vector specifying the metadata elements to
extract. Defaults to every field chromConverter attaches; no format
records all of them, so the elements a format does not provide are
absent from the result. Superseded names (e.g. |
format_out |
Class of the table. Either |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse a field holding more than one
value ( |
expand |
Whether to include the nested metadata fields, whose value is
itself a list or table rather than a single value per chromatogram: the
|
digits |
Number of significant digits for the numbers in a field
collapsed into a string (see |
progress_bar |
Logical. Whether to show progress bar. Defaults to |
cl |
Argument to pbapply specifying the number
of parallel workers to use or a cluster object created by
makeCluster. Defaults to |
verbose |
Logical. Whether to print status messages, and the output of external parsers, to the R console. |
sample_names |
Which sample names to use. Options are |
sort_by |
How to sort the chromatograms: |
... |
Additional arguments to the parser. Arguments that a format's metadata reader does not take are ignored. |
The formats that are slow to read in full are read without decoding the
data: 'Agilent' .uv, 'Chromeleon', 'OpenLab' .dx, 'Shimadzu' .lcd,
.gcd, .qgd and ASCII, 'Thermo' RAW, 'Varian' SMS and 'Waters' .arw
files, and ANDI (.cdf), mzML and mzXML. 'OpenLab' 131 .uv files are the
exception: their scaling is worked out from the data, so they are decoded in
full. Other formats are read in full and their metadata extracted.
The 'OpenLab' .dx and 'Shimadzu' formats report only the fields that
describe the whole file, leaving out those of its traces, such as
detector or wavelength. 'Thermo' RAW files leave out the fields that
come from the mzML they are converted to, such as detector_range.
If parser is not given, each format is read with the parser that can skip
the data, which for .uv files is chromconverter even where 'Entab' is
installed.
A data.frame, data.table or tibble with one row per sample
and one column per metadata field, as described in extract_metadata. A
table with no rows if none of the files could be read.
Ethan Bass
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") read_metadata(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE, what = c("sample_name", "run_datetime", "method"))path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") read_metadata(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE, what = c("sample_name", "run_datetime", "method"))
Extracts data from mzML files using parsers from either RaMS or mzR.
read_mzml( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), parser = c("RaMS", "mzR"), what = c("MS1", "MS2", "BPC", "TIC", "DAD", "chroms", "metadata", "everything"), verbose = FALSE, ... )read_mzml( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), parser = c("RaMS", "mzR"), what = c("MS1", "MS2", "BPC", "TIC", "DAD", "chroms", "metadata", "everything"), verbose = FALSE, ... )
path |
Path to |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
parser |
What parser to use. Either |
what |
What types of data to return (argument to RaMS::grabMSdata).
Options include |
verbose |
Argument to |
... |
Additional arguments to |
Both parsers return a list with one element per stream in
what. Mass spectra and EICs are always long. With data_format = "wide" (the
default), TIC and BPC are returned as 2D chromatograms of class
format_out, and DAD as a wide chromatogram of class format_out; with
"long", every stream is a long data.table.
The chroms stream holds the chromatograms stored in the file, such as the
SIM and SRM traces of a triple quadrupole run. In wide format it is a list
of 2D chromatograms named by their ID in the file (or Chromatogram 1,
Chromatogram 2 and so on where it has none), each with the precursor_mz
and product_mz it monitors as attributes. If any trace repeats a retention
time, as in some malformed files, the whole stream is returned as the long
data.table instead, with a warning.
The mzR parser reads files that RaMS cannot, such as those compressed with
MS-Numpress. It returns only MS1, MS2, BPC, TIC and DAD, and no
file metadata. Its TIC and BPC are the per-scan values recorded in the
MS1 spectra.
A named list of the streams in what.
Ethan Bass
## Not run: read_mzml("path/to/file.mzML") ## End(Not run)## Not run: read_mzml("path/to/file.mzML") ## End(Not run)
Reads peak lists from specified folders or vector of paths.
read_peaklist( paths, find_files, format_in = c("chemstation", "shimadzu_fid", "shimadzu_dad", "shimadzu_lcd", "shimadzu_gcd", "chromatotec", "asm", "cdf", "openlab"), pattern = NULL, peaktable_format = c("chromatographr", "original"), metadata_format = c("chromconverter", "raw"), read_metadata = TRUE, progress_bar, cl = 1, sort_by = c("auto", "none", "acquisition_time", "file_time"), data_format = NULL )read_peaklist( paths, find_files, format_in = c("chemstation", "shimadzu_fid", "shimadzu_dad", "shimadzu_lcd", "shimadzu_gcd", "chromatotec", "asm", "cdf", "openlab"), pattern = NULL, peaktable_format = c("chromatographr", "original"), metadata_format = c("chromconverter", "raw"), read_metadata = TRUE, progress_bar, cl = 1, sort_by = c("auto", "none", "acquisition_time", "file_time"), data_format = NULL )
paths |
Paths to files or folders containing peak list files. |
find_files |
Logical. Whether to treat the supplied paths as directories to search for files. Inferred if not supplied, by testing whether every path is a file. |
format_in |
Format of files to be imported/converted. One of
|
pattern |
A pattern (e.g. a file extension). Defaults to |
peaktable_format |
Whether to return peak tables in the standard
|
metadata_format |
Format to output metadata. Either |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
progress_bar |
Logical. Whether to show progress bar. Defaults to |
cl |
Argument to pbapply specifying the number of
parallel workers to use or a cluster object created by
makeCluster (a set of parallel R worker processes).
Defaults to |
sort_by |
How to sort the samples: |
data_format |
Deprecated. Use |
A peak_list: a list with one element per sample, holding its peak
table, or a list of peak tables where the file records more than one. The
tables are named by wavelength (e.g. "254") where the file records one,
and otherwise by the file's own name for the signal; a table identical to
another at the same wavelength is a copy and is left out. Each row is a
peak. Every table starts with a sample column and
a lambda column giving the signal's wavelength, which is NA for a
detector without one or a file that does not record it, followed by the
columns of peaktable_format.
Ethan Bass
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") peak_list <- read_peaklist(path, progress_bar = FALSE) names(peak_list) peak_list[["BENZOS_250PPM"]][["254"]]path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") peak_list <- read_peaklist(path, progress_bar = FALSE) names(peak_list) peak_list[["BENZOS_250PPM"]][["254"]]
Reads 'Shimadzu' ASCII (.txt) files. These files can be exported from
'Shimadzu LabSolutions' by right clicking on samples in the sample list and
selecting File Conversion:Convert to ASCII.
read_shimadzu( path, what = "chroms", format_in = NULL, include = c("fid", "lc", "dad", "uv", "tic"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), peaktable_format = c("chromatographr", "original"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), ms_format = c("data.frame", "list"), collapse = TRUE, scale = TRUE )read_shimadzu( path, what = "chroms", format_in = NULL, include = c("fid", "lc", "dad", "uv", "tic"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), peaktable_format = c("chromatographr", "original"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), ms_format = c("data.frame", "list"), collapse = TRUE, scale = TRUE )
path |
Path to Shimadzu |
what |
Whether to extract chromatograms ( |
format_in |
This argument is deprecated and is no longer required. |
include |
Which chromatograms to include: any of |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
peaktable_format |
Whether to return peak tables in the standard
|
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
ms_format |
Whether to return mass spectral data as a (long)
|
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
scale |
Whether to scale the data by the scaling factor present in the
file. Defaults to |
A nested list of elements from the specified file, where the top
levels are chromatograms, peak tables, and/or mass spectra according to the
value of what, and the chromatograms are grouped by type (e.g. fid).
Where collapse is TRUE, a list of one is unwrapped at the top level and
within each type of chromatogram. Chromatograms are returned in the format specified by
format_out and data_format.
Ethan Bass
Other 'Shimadzu' parsers:
read_shimadzu_gcd(),
read_shimadzu_lcd(),
read_shimadzu_method(),
read_shimadzu_qgd(),
read_sz_lcd_2d(),
read_sz_lcd_3d(),
read_sz_tables()
path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") read_shimadzu(path)path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") read_shimadzu(path)
Read chromatogram data streams from 'Shimadzu' .gcd files.
read_shimadzu_gcd( path, what = "chroms", format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, peaktable_format = c("chromatographr", "original") )read_shimadzu_gcd( path, what = "chroms", format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE, peaktable_format = c("chromatographr", "original") )
path |
Path to 'Shimadzu' |
what |
What stream to get: current options are chromatograms
( |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
peaktable_format |
Whether to return peak tables in the standard
|
A parser to read chromatogram data streams from 'Shimadzu' .gcd files.
GCD files are encoded as 'Microsoft' OLE documents. The parser relies on the
olefile package in Python to unpack the
files. The chromatogram data is encoded in streams titled
LSS Raw Data:Chromatogram Ch<#>. Each stream begins with a 24-byte
header:
4 bytes: segment label (17234).
4 bytes: Little-endian integer specifying the sampling interval in milliseconds.
4 bytes: Little-endian integer specifying the number of values in the stream.
4 bytes: Little-endian integer specifying a byte count, which does not match the size of the stream exactly.
8 bytes of 00s
After the header, the data are encoded as 64-bit (little-endian)
floating-point numbers. Retention times are derived from the number of
values and the sampling interval encoded in the header, rather than read
from the file: the nth value is placed at n times the sampling
interval.
A 2D chromatogram in the format specified by data_format and
format_out. If data_format is wide, the chromatogram will be returned
with retention times as row names and a single column for the intensity. If
long format is requested, two columns will be returned: one for the
retention time and one for the intensity. The format_out argument
determines whether the chromatogram is returned as a matrix, data.frame,
or data.table. Metadata are attached to the chromatogram as attributes
if read_metadata is TRUE.
Ethan Bass
Other 'Shimadzu' parsers:
read_shimadzu(),
read_shimadzu_lcd(),
read_shimadzu_method(),
read_shimadzu_qgd(),
read_sz_lcd_2d(),
read_sz_lcd_3d(),
read_sz_tables()
## Not run: read_shimadzu_gcd("path/to/file.gcd") ## End(Not run)## Not run: read_shimadzu_gcd("path/to/file.gcd") ## End(Not run)
Read PDA, chromatogram, mass spectrometry and peak table streams from
'Shimadzu' .lcd files.
read_shimadzu_lcd( path, what, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), scale = TRUE, sparse = TRUE, centroided = TRUE, collapse = TRUE, peaktable_format = c("chromatographr", "original") )read_shimadzu_lcd( path, what, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), scale = TRUE, sparse = TRUE, centroided = TRUE, collapse = TRUE, peaktable_format = c("chromatographr", "original") )
path |
Path to 'Shimadzu' |
what |
What stream to get: current options are If a stream is not specified, the richest one the file contains is returned:
|
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
scale |
Whether to scale the data by the scaling factor present in the
file. Defaults to |
sparse |
Logical. Whether to return mass spectra in sparse format
(excluding zeros), as |
centroided |
Logical. Whether to return the centroided single
quadrupole scans ( |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
peaktable_format |
Whether to return peak tables in the standard
|
A parser to read data from 'Shimadzu' .lcd files. LCD files are
encoded as 'Microsoft' OLE documents. The parser relies on the
olefile package in Python to unpack the
files. Each detector writes its own storage, and this function dispatches
over them:
PDA (PDA 3D Raw Data:3D Raw Data), requested as DAD: one
delta-encoded segment per retention time, each holding a full spectrum.
Read by read_sz_lcd_3d(), which documents the segment header and the
delta encoding.
Chromatograms (LSS Raw Data:Chromatogram Ch<#>): one stream per
channel, delta-encoded in the same way. Read by read_sz_lcd_2d().
Quadrupole time-of-flight mass spectra (QTFL RawData): centroided
scans stored as a scan header, a block of flight times and a block of
intensities, with the mass axis reconstructed from the calibration table in
the file. Read by read_sz_qtof(), which documents the scan header, the
flight-time conversion and the intensity scaling. The total ion current is
held separately, in Centroid SumTIC (read_sz_qtof_tic()).
Triple quadrupole mass spectra (TLM Raw Data): zlib-compressed scan
records located through a spectrum index, covering full scan, product-ion
scan, MRM and SIM acquisitions. Read by read_sz_tlm(), which documents the
index, the scan header and the layout of each scan type. The total ion
current is again held separately, in TIC Data.
Ion trap time-of-flight mass spectra (TTFL Raw Data): run-length
encoded profile scans from the LCMS-IT-TOF, with the mass axis interpolated
between the calibrant ions stored in the file. Read by read_sz_ittof(),
which documents the scan header, the encoding and the calibration. The total
ion current is read from the scan headers (read_sz_ittof_tic()).
Single quadrupole mass spectra (Mass Raw Data): centroided and
profile scans from instruments such as the LCMS-2020, located through a
spectrum index. Read by read_sz_sq(), which documents the scan header,
the records and the approximate profile m/z axis. The
total ion current is held separately, in TIC Data (read_sz_sq_tic()).
Peak tables (Peak Table): integration results as reported by
'LabSolutions', one stream per channel. Read by read_sz_tables(), which
documents the two record layouts.
The mass spectrometry containers are mutually exclusive: a file holds one of them, according to the instrument that wrote it.
A mass spectrometry run is divided into acquisition events: the scan
functions defined by the method, each with its own polarity, MS level and
mass range, which the instrument cycles through as the run proceeds. The
mass spectrometry streams are reported per event — TIC returns one
chromatogram for each, and the scan_info attribute of a table of spectra
names the event every scan came from.
A named list with one element per stream requested, or the element
itself where there is only one and collapse is TRUE. Chromatograms and
the PDA data are returned in the format specified by data_format and
format_out. In wide format, retention times are the rows, and each 2D
chromatogram has a single intensity column while the PDA data have one
column per wavelength. If long format is requested, the retention time
and the intensity are returned as columns, alongside the detector, channel,
wavelength and unit for a 2D chromatogram. The format_out argument
determines whether they are returned in matrix, data.frame, or
data.table format. Mass spectra and peak tables are always long.
Metadata are attached as attributes when read_metadata is TRUE.
Times are stored as a 'Windows' FILETIME, which is always UTC, so
run_datetime is reported in UTC. The files also record the offset of the
local time zone (e.g. +01'00'), but this is the standard offset of the
zone rather than the offset that was in force, and it seems that no daylight
saving information is stored anywhere in the file. The local times displayed by
'LabSolutions' therefore cannot be reconstructed from the recorded offset
alone: where daylight saving time applied, they are an hour ahead of it.
Rendering run_datetime in the zone where the data were acquired, e.g.
format(attr(x, "run_datetime"), tz = "Europe/Paris"), recovers them
exactly.
As of v0.10.0, 2D chromatograms are scaled by the calibration factor and
the value factor recorded for each channel, so their intensities match those
reported by 'LabSolutions'. An absorbance axis can be reported in uAU,
mAU or AU, and the file records the size of each as a value factor:
1, 1000 and 1e6, since one mAU is a thousand uAU and one AU a
million. The smallest of them is the base unit, while 'LabSolutions'
displays the data in whichever unit the method selected, usually mAU.
Other detectors work the same way: a refractive index axis measures in nRI
and displays uRI.
Two factors separate the stored integers from the displayed value. The
calibration factor converts an integer into base units, and the value factor
converts base units into the displayed unit; an intensity as 'LabSolutions'
reports it is the integer times the one divided by the other. The
calibration factor is 1 on some channels and not on others (e.g. about
0.024 for an SPD-20A and 0.0032 for an RID-10A), which suggests the
integers are detector counts whose size varies by module, though the file
does not say so.
For a 2D chromatogram, scale = TRUE applies both factors. scale = FALSE
returns the stored integers. Where the calibration factor is 1, their
detector_y_unit is the base unit (e.g. uAU), and the values and the
attribute agree. Where it is not, the integers are in no unit we can name,
so detector_y_unit is NA; the scaled attribute records which of the
two was returned.
PDA data is instead returned as it is encoded in the file, matching the
[PDA 3D] section of a 'LabSolutions' ASCII export, which declares no
intensity unit or multiplier. The 3D Data Item describes the absorbance
axis in mAU with a value factor of 1000, which would imply scaling the
values by 0.001, but the [PDA Multi Chromatogram] traces in the ASCII
export, which are extracted from the same data, report values on the same
scale as the raw data with a multiplier of 1. Until this can be resolved,
PDA data is left unscaled and the scale argument is ignored.
Max Plot is the maximum absorbance over the wavelength range at each point
in time, so the value at one time can come from a different wavelength than
the value at the next, and no single wavelength describes the trace. It is
derived from the PDA data but is read as a 2D chromatogram, so it is scaled
and currently differs from the PDA data by a factor of 1000. The
wavelength range it was taken over is not recorded in the 2D Data Item,
whose nanometer axis spans 0 to 0, so its wavelength attribute is NA
rather than the acquisition range of the PDA stream.
Ethan Bass
Other 'Shimadzu' parsers:
read_shimadzu(),
read_shimadzu_gcd(),
read_shimadzu_method(),
read_shimadzu_qgd(),
read_sz_lcd_2d(),
read_sz_lcd_3d(),
read_sz_tables()
## Not run: read_shimadzu_lcd(path) ## End(Not run)## Not run: read_shimadzu_lcd(path) ## End(Not run)
Reads the instrument settings stored with a 'Shimadzu' GC run (.gcd), LC
run (.lcd) or GC-MS run (.qgd), such as the oven program, gradient,
flows and column.
read_shimadzu_method( path, what = NULL, format_out = c("data.frame", "tibble", "data.table") )read_shimadzu_method( path, what = NULL, format_out = c("data.frame", "tibble", "data.table") )
path |
Path to a |
what |
One or more modules to read. For GC runs, any of |
format_out |
Class of the tables returned: |
Method parameters are attached automatically to every chromatogram and
peak table read from these files, in the method_params metadata field.
This includes all scalar values but leaves out the oven program, gradient
and other tables, which are only returned by this function. The ms module
of a GC-MS or LC-MS run is attached as ms_params.
A named list with one element per module.
For GC runs:
oven: a list with scalar elements equilibration_time_min,
initial_temperature_C and initial_hold_min, plus program, a table of
the temperature ramps with columns rate_C_min, temperature_C and
hold_min.
injector: a list with scalar elements name, temperature_C,
split_ratio, column_flow_mL_min, linear_velocity_cm_s,
pressure_kPa, total_flow_mL_min and purge_flow_mL_min.
detector: a list with scalar elements name, temperature_C,
h2_flow_mL_min, air_flow_mL_min, makeup_flow_mL_min and
sampling_rate_ms.
autosampler: a list with scalar element injection_volume_uL.
column: a list with scalar elements name, length_m,
diameter_mm, film_thickness_um, max_temperature_C and
serial_number.
For GC-MS runs, oven, injector, autosampler and column as for GC
runs, and ms, a list with scalar elements start_time_min and
end_time_min (the window in which the mass spectrometer acquires),
ion_source_temperature_C, interface_temperature_C and event_time_s.
Files without the labeled method (e.g. from a GC-2010) record no
equilibration_time_min, injector name or pressure_kPa,
injection_volume_uL, column diameter_mm or film_thickness_um, or
interface_temperature_C, which are then NA. A split ratio of -1
appears to mean the split is off. The injector settings are the values at
the start of the run; a method may program the pressure or purge flow to
change later, so a purge flow of 0 can be the start of a purge program.
For LC runs:
pump: a list with scalar elements mode, the abbreviation
'LabSolutions' stores for the pump mode (e.g. ISO, BGE or LPGE),
flow_mL_min and stop_time_min, plus gradient, a table with columns
time_min and pct_B, and solvents, a table of the mobile phase names
entered in the method, with columns pump, line and solvent, or
NULL if none were entered. The gradient starts from the pump's initial
concentration of B at time 0 and changes linearly between the times
listed. It is NULL for an isocratic run whose time program sets no
concentration. flow_mL_min is NA if the method sets no flow.
column: a list with scalar element temperature_C, the temperature
of the column oven, which is NA if the oven is not in use.
ms: the ion source interface of a single or triple quadrupole mass
spectrometer, a list with scalar elements dl_temperature_C, the
temperature of the desolvation line (CDL on single quadrupole
instruments), and heat_block_temperature_C. It is attached to the
chromatograms as ms_params.
dad: the PDA detector, a list with scalar elements
start_wavelength_nm, end_wavelength_nm, sampling_interval_ms,
end_time_min and cell_temperature_C (NA if the cell is not
thermostatted), plus
channels, a table of the channels the acquisition method extracts, with
columns channel, wavelength_nm and bandwidth_nm. Data processing can
change these channels; the wavelengths of the peak tables are those of the
processed channels.
.gcd and .lcd files store the method and instrument configuration as
labeled XML, in the GUC.1.METHOD and GUC.1.CONFIG streams, and the PDA
settings in PDA.1.METHOD. The settings of a single or triple quadrupole
mass spectrometer are records stored as hex in the same XML, in the
LCMS unit of its own GUC.1.METHOD or GUM.METHOD stream; of these,
only the interface record (Ifs) is read, whose DL and heat block
temperatures are uint16 in hundredths of a degree at bytes 70 and 74.
They were checked against a method printout for an 'LCMS-2020' and the
published method of an 'LCMS-8040'.
.qgd files from a GC-2030 (e.g. with a 'GCMS-QP2020 NX') also hold the GC
method and configuration as labeled XML, in GCMS Configuration/GUC_GC2,
and their oven, injector, autosampler and column settings are read from it
as for .gcd files. Every .qgd file stores the method as unlabeled binary
records, one stream per module, at fixed byte offsets, which are read for the
other settings and for files without the XML. Values are little-endian
float32 unless marked otherwise, and bytes not listed are not read. The same
streams are found in files from 'GCMS-QP2010' and 'QP2020 NX' instruments:
GC-2010 Instrument Parameters/Column Oven Parameter, 260 bytes:
8: the number of ramps, n (int32).
12, 16: the initial temperature and hold.
20, 100, 180: the rates, target temperatures and holds, each an array of 20 slots, of which those past n are zero.
GC-2010 Instrument Parameters/Injection Parameter-1, 512 bytes:
12, 16, 20: the column flow, linear velocity and split ratio.
24, 120, 216, 312: the temperature, total flow, pressure and purge flow programs, 96 bytes each: the number of ramps (int32), the initial value and hold, then arrays of 7 rates, targets and holds.
GCMS Configuration/Column-1, 832 bytes:
0, 64: the column name and serial number, null-terminated strings of up to 64 bytes.
132: the length in tenths of a metre (int32).
140: the maximum temperature (int32).
QP5K Instrument Parameters/MS Parameter, 600 or 664 bytes:
20: the ion source temperature in tenths of a degree (int32).
44, 48: the start and end of acquisition in milliseconds (int32).
52: the event time in milliseconds (int32).
The interface temperature is only read from the XML, as the additional
heater the configuration names MS. Method heaters are numbered by their
position in the configuration's list of heaters, which starts at 2, so the
MS heater is method heater 4 in every file seen.
The settings were checked against the 'GCMSsolution' method printouts published with three 'QP2020 NX' runs.
Ethan Bass
read_chemstation_method and read_agilent_amx for 'Agilent' methods.
Other 'Shimadzu' parsers:
read_shimadzu(),
read_shimadzu_gcd(),
read_shimadzu_lcd(),
read_shimadzu_qgd(),
read_sz_lcd_2d(),
read_sz_lcd_3d(),
read_sz_tables()
## Not run: method <- read_shimadzu_method("path/to/file.gcd") method$oven$program ## End(Not run)## Not run: method <- read_shimadzu_method("path/to/file.gcd") method$oven$program ## End(Not run)
Reads 'Shimadzu GCMSsolution' .qgd GC-MS data files.
read_shimadzu_qgd( path, what = c("MS1", "MS2", "TIC"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )read_shimadzu_qgd( path, what = c("MS1", "MS2", "TIC"), format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), collapse = TRUE )
path |
Path to 'Shimadzu' |
what |
What stream to get: current options are full scans ( |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
The MS data is stored in the GCMS Raw Data storage, which contains an
MS Raw Data stream with MS scans, a TIC Data stream containing the total
ion chromatogram, and a Retention Time stream containing the retention
times. All known values are little-endian. The retention time stream is an
array of 4-byte integers giving the time of each scan in milliseconds, and
the TIC stream an array of 8-byte integers, one per retention time.
The MS Raw Data stream holds one block per scan, located through the
Spectrum Index stream. The index is an array of byte offsets, held as
4-byte integers in some files and as 8-byte integers after a 2-byte header in
others, such as the MRM files seen so far. Each block begins with a 32-byte
header:
scan number (4-byte integer)
retention time in milliseconds (4-byte integer)
unknown (12 bytes)
number of bytes in each intensity value (2-byte integer)
number of m/z values in the block (2-byte integer)
MRM event number (2-byte integer)
number of MRM transitions in the block (2-byte integer)
unknown (4 bytes)
In a full scan, each m/z value is followed by its intensity. The m/z values
are 2-byte integers holding m/z times 20. Intensities are unsigned integers
of the width given in the header, except that the top bit of a 4-byte
intensity is dropped, since it appears to flag a saturated value, as it does
in 'Shimadzu' triple quadrupole .lcd files.
An MRM scan leaves the width and the number of m/z values at zero and instead holds one record per transition: the precursor and product m/z, each stored like the m/z of a full scan, followed by an intensity, an unsigned integer whose top bit is dropped when it is 4 bytes wide. No MRM file with 4-byte intensities has been seen. The header doesn't give the intensity width, so the reader works it out from the size of the block.
A list holding whichever of the requested spectra the file has
(MS1, MS2) and the TIC, or the one requested where collapse is
TRUE. The TIC is returned in the format specified by
data_format and format_out. If data_format is wide, it is returned
with retention times as rows and a single column for the intensity. If
long format is requested, two columns are returned: one for the retention
time and one for the intensity. The format_out argument determines
whether it is returned as a matrix, data.frame, or data.table. The
spectra are always long, with columns
scan, rt, mz and intensity, plus precursor_mz before mz in the
MRM spectra, and a matrix resolves to a
data.table. Each table of spectra has a scan_info attribute with one row
per scan, giving its scan, rt, ms_level and scan_type ("scan" or
"MRM"). Metadata are attached as attributes if read_metadata is
TRUE.
Ethan Bass
Other 'Shimadzu' parsers:
read_shimadzu(),
read_shimadzu_gcd(),
read_shimadzu_lcd(),
read_shimadzu_method(),
read_sz_lcd_2d(),
read_sz_lcd_3d(),
read_sz_tables()
## Not run: read_shimadzu_qgd("path/to/file.qgd") ## End(Not run)## Not run: read_shimadzu_qgd("path/to/file.qgd") ## End(Not run)
Converts a 'Thermo' .raw file to mzML with the ThermoRawFileParser and reads the result with
read_mzml.
read_thermoraw( path, path_out = NULL, format_out = c("matrix", "data.frame", "data.table"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), centroid = TRUE, verbose = getOption("verbose") )read_thermoraw( path, path_out = NULL, format_out = c("matrix", "data.frame", "data.table"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw"), centroid = TRUE, verbose = getOption("verbose") )
path |
Path to 'Thermo' |
path_out |
Path to directory to export |
format_out |
Class of output. Either |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
centroid |
Logical. Whether to centroid profile spectra with the vendor's
peak picking. Defaults to |
verbose |
Logical. Whether to print output from ThermoRawFileParser to the console. Ignored on Windows, where the output is always printed. |
The ThermoRawFileParser must be installed separately.
A list of chromatograms, as returned by read_mzml, in the format
specified by format_out.
If path_out is specified, the mzML file (and,
if read_metadata is TRUE, a metadata .txt file) is left there.
Ethan Bass
Hulstaert Niels, Jim Shofstahl, Timo Sachsenberg, Mathias Walzer, Harald Barsnes, Lennart Martens, and Yasset Perez-Riverol. ThermoRawFileParser: Modular, Scalable, and Cross-Platform RAW File Conversion. Journal of Proteome Research 19, no. 1 (January 3, 2020): 537–42. doi:10.1021/acs.jproteome.9b00328.
Other external parsers:
call_entab(),
call_openchrom(),
call_rainbow(),
sp_converter(),
uv_converter()
## Not run: read_thermoraw(path) ## End(Not run)## Not run: read_thermoraw(path) ## End(Not run)
Read peak list(s) from 'Varian MS Workstation'.
read_varian_peaklist(path)read_varian_peaklist(path)
path |
Path to 'Varian' peak list file. |
A data.frame containing the information from the specified report.
Ethan Bass
Other 'Varian' parsers:
read_varian_sms()
## Not run: read_varian_peaklist(path) ## End(Not run)## Not run: read_varian_peaklist(path) ## End(Not run)
Reads 'Varian Workstation' SMS files.
read_varian_sms( path, what = c("MS1", "TIC", "BPC"), format_out = c("matrix", "data.frame", "data.table"), data_format = "long", read_metadata = TRUE, collapse = TRUE )read_varian_sms( path, what = c("MS1", "TIC", "BPC"), format_out = c("matrix", "data.frame", "data.table"), data_format = "long", read_metadata = TRUE, collapse = TRUE )
path |
Path to a 'Varian' |
what |
Which streams to get: mass spectra ( |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
collapse |
Logical. Whether to collapse lists that only contain a single
element. Defaults to |
Varian SMS files begin with a DIRECTORY holding the offsets of each
section. The first section is MSData, which begins at byte 3238 in every
file seen so far, and is itself divided in two. The first part, after a short
header, holds chromatogram data, one record per scan: the scan number, the
retention time (as a 64-bit float), the ion time (µsec, as a 2-byte unsigned
integer), the total ion chromatogram (TIC), the base peak chromatogram
(BPC), and further unidentified fields. The scan numbers and the
TIC and BPC intensities are stored as 4-byte little-endian integers. A run of
null bytes then separates this part from the segments holding the mass
spectra.
The mass spectra are encoded differently. Each scan is a series of
variable-length values, separated from the next scan by two null bytes.
Within a scan the values are paired: the first of each pair is the
delta-encoded mass-to-charge ratio and the second is the intensity. Each
value is a big-endian integer whose length, 1 + (d %/% 4) bytes, and bit
width are set by its leading hexadecimal digit (d). Values beginning with
0-3 are single bytes. For d >= 4, the lowest n bits are preserved
according to the following scheme:
d = 4-5 -> preserve lowest 13 bits
d = 6-7 -> preserve lowest 14 bits
d = 8-9 -> preserve lowest 21 bits
d = 10-11 (A-B) -> preserve lowest 22 bits
d = 12-13 (C-D) -> preserve lowest 27 bits
d = 14-15 (E-F) -> preserve lowest 28 bits
No file seen so far carries a leading digit above C, so the rules for D
and for E-F are extrapolated from the others rather than observed.
A chromatogram or list of chromatograms from the specified file,
according to the value of what. Chromatograms are returned in the format
specified by format_out, except that mass spectra are returned as a
data.table when format_out is matrix.
There is still only limited support for the extraction of metadata from this file format.
Ethan Bass
Other 'Varian' parsers:
read_varian_peaklist()
## Not run: read_varian_sms(path) ## End(Not run)## Not run: read_varian_sms(path) ## End(Not run)
Reads 'Waters' ASCII .arw files.
read_waters_arw( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw") )read_waters_arw( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw") )
path |
Path to Waters |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
For help exporting files from Empower, you can consult the official documentation: How_to_export_3D_raw_data_from_Empower.
A chromatogram in the format specified by the format_out and
data_format arguments.
Ethan Bass
Other 'Waters' parsers:
read_waters_raw()
## Not run: read_waters_arw("path/to/file.arw") ## End(Not run)## Not run: read_waters_arw("path/to/file.arw") ## End(Not run)
Reads 'Waters MassLynx' (.raw) files into R.
read_waters_raw( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw") )read_waters_raw( path, format_out = c("matrix", "data.frame", "data.table"), data_format = c("wide", "long"), read_metadata = TRUE, metadata_format = c("chromconverter", "raw") )
path |
Path to Waters |
format_out |
Class of output. Either |
data_format |
Whether to return data in |
read_metadata |
Logical. Whether to attach metadata. Defaults to |
metadata_format |
Format to output metadata. Either |
A list of 2D chromatograms, one per trace and named by it, in the
format specified by format_out and data_format.
This parser reads only 2D chromatograms (retention time and intensity), not mass spectra or DAD data.
Ethan Bass
Other 'Waters' parsers:
read_waters_arw()
## Not run: read_waters_raw("path/to/file.raw") ## End(Not run)## Not run: read_waters_raw("path/to/file.raw") ## End(Not run)
Retains the chromatograms of a chrom_list whose metadata meet the specified
condition, such as sample_name == "blank" or
run_datetime > as.POSIXct("2024-01-01", tz = "UTC"). The condition can
refer to any field extract_metadata reports, such as sample_name or
method, as well as the chromatogram's name in the list.
## S3 method for class 'chrom_list' subset(x, subset, ...)## S3 method for class 'chrom_list' subset(x, subset, ...)
x |
A |
subset |
An expression giving a single |
... |
Ignored. |
Numeric fields such as time_range and sample_injection_volume compare
as numbers wherever the file's value parses as one, and a field with several
values can be indexed (e.g. time_range[2]). A field a chromatogram does not
carry is NA, and a chromatogram for which
subset is NA is dropped, as in subset() for data frames. Where an
element holds several chromatograms, such as the traces read_agilent_d
returns for each .D directory, it is kept or dropped as a whole, and
subset sees the fields its chromatograms agree on, ignoring those that
leave a field empty; a field they disagree on is NA.
A chrom_list containing the selected chromatograms.
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) subset(chroms, sample_name != "MEOH") subset(chroms, run_datetime < as.POSIXct("2023-06-21", tz = "UTC"))path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) subset(chroms, sample_name != "MEOH") subset(chroms, run_datetime < as.POSIXct("2023-06-21", tz = "UTC"))
Returns what print.chrom_list displays as a table, with one row per
chromatogram: the sample it belongs to, its size, and the metadata fields
in cols. Unlike print, nothing is collapsed into a header, abbreviated
or truncated to the first few rows, so the result can be filtered and
joined against.
## S3 method for class 'chrom_list' summary( object, cols = chrom_summary_cols(), format_out = c("data.frame", "data.table", "tibble"), digits = NULL, ... )## S3 method for class 'chrom_list' summary( object, cols = chrom_summary_cols(), format_out = c("data.frame", "data.table", "tibble"), digits = NULL, ... )
object |
A |
cols |
Character vector of attribute names to report. Defaults to:
|
format_out |
Format of object. Either |
digits |
Number of significant digits for the numbers in a field
collapsed into a string, or |
... |
Additional arguments (currently ignored). |
A data.frame, data.table or tibble (according to the value of
format_out) with one row per chromatogram. The first columns describe
where the chromatogram sits and how large it is — sample, trace (only
when a sample holds more than one), n_rows and n_cols — followed by one
column per metadata field found. A field no chromatogram records, or that
every one of them leaves empty, is dropped rather than filled with NA. A
field holding more than one value, such
as the product_mz of an MRM event monitoring several transitions, is
collapsed to a comma-separated string so that it occupies one column.
extract_metadata, print.chrom_list
path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) summary(chroms)path <- system.file("extdata", "benzoxazinoid_standards", package = "chromConverter") chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A", parser = "chromconverter", progress_bar = FALSE) summary(chroms)
Writes a copy of an 'OpenLab CDS' acquisition method (.amx) with a new
pump gradient, flow, stop time, post time or column temperature. All other
settings are copied unchanged from the template.
write_agilent_amx( path, path_out, gradient = NULL, flow = NULL, stop_time = NULL, post_time = NULL, temperature = NULL, force = FALSE )write_agilent_amx( path, path_out, gradient = NULL, flow = NULL, stop_time = NULL, post_time = NULL, temperature = NULL, force = FALSE )
path |
Path to the template |
path_out |
Path to write the new method. |
gradient |
A table of solvent composition over time (see Details).
|
flow |
Flow rate in mL/min. |
stop_time |
Pump stop time in minutes. |
post_time |
Pump post time in minutes, at least 0.01. |
temperature |
Column temperature in degrees Celsius. |
force |
Whether to overwrite |
The writer has only been tested on methods for a G7104C quaternary pump and a G7116A column compartment. Other modules may lay out their methods differently. If the writer fails on one of your methods, or writes one that OpenLab will not load, please open an issue and attach the template. Open each written method in OpenLab and check its settings before you run it.
gradient takes the table that read_agilent_amx() returns as
pump$gradient, in wide or long format. It needs a percentage for every
solvent channel the template uses, and each row must add up to 100. It
must have a row at time zero, which sets the starting composition. The
other rows replace the composition steps in the pump timetable. Flow steps
in the timetable are kept, and gradient cannot change them. If the
template has flow steps, drop the flow_mL_min column (or the "flow" rows
in long format) from the table read_agilent_amx() returns.
Setting flow gives a constant flow rate and removes the template's flow
steps.
temperature sets both sides of the column compartment, and the template
must already control the temperature. A template whose compartment is set
to "Not Controlled" gives an error.
Setting stop_time also sets the run time of the method. The checksum of
each edited part is recalculated. The Agilent/ReportableInformation part,
which repeats the settings as formatted text, is not rewritten and still
describes the template.
The writer needs the 'zip' package.
Invisibly returns path_out.
Other write functions:
write_andi_chrom(),
write_andi_ms(),
write_chroms(),
write_mzml()
## Not run: gradient <- data.frame(time_min = c(0, 2, 8), pct_A = c(70, 70, 5), pct_B = c(30, 30, 95)) write_agilent_amx("template.amx", "new.amx", gradient = gradient, stop_time = 10) ## End(Not run)## Not run: gradient <- data.frame(time_min = c(0, 2, 8), pct_A = c(70, 70, 5), pct_B = c(30, 30, 95)) write_agilent_amx("template.amx", "new.amx", gradient = gradient, stop_time = 10) ## End(Not run)
Exports a chromatogram in ANDI (Analytical Data Interchange) chromatography
format (ASTM E1947-98). The format holds a single trace, so a 3D
chromatogram must be reduced to one: name the column to export with the
lambda argument, or the first column is exported with a warning.
write_andi_chrom(x, path_out, sample_name = NULL, lambda = NULL, force = FALSE)write_andi_chrom(x, path_out, sample_name = NULL, lambda = NULL, force = FALSE)
x |
A chromatogram in (wide) format. |
path_out |
The path to write the file. |
sample_name |
The name of the file. If a name is not provided, the name
will be derived from the |
lambda |
The wavelength to export, for a 3D chromatogram. Either a
string matching one of the columns of |
force |
Whether to overwrite existing files at the specified path.
Defaults to |
Retention times are written in the unit the chromatogram reports, declared
in the file's mandatory retention_unit attribute as Minutes or
Seconds. A chromatogram whose time_unit is missing or unrecognized is
taken to be in minutes, since the attribute cannot be left unset. The run
length, delay time and sampling interval are derived from the retention
times, and detector_maximum_value and detector_minimum_value report the
range of the exported trace. actual_sampling_interval is the mean of the
intervals, and uniform_sampling_flag reports whether every interval
matches that mean. The per-point times are written to raw_data_retention
either way, which is what a reader needs where the flag is N.
Invisibly returns the path to the written CDF file.
Exports a chromatogram in ANDI chromatography format (netCDF) in the directory
specified by path_out. The file will be named according to the value
of sample_name. If no sample_name is provided, the sample_name
attribute will be used if it exists.
Ethan Bass
Other write functions:
write_agilent_amx(),
write_andi_ms(),
write_chroms(),
write_mzml()
path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") chrom <- read_shimadzu(path, what = "chroms") # the file is named for the `sample_name` attribute unless one is supplied write_andi_chrom(chrom, path_out = tempdir(), force = TRUE)path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") chrom <- read_shimadzu(path, what = "chroms") # the file is named for the `sample_name` attribute unless one is supplied write_andi_chrom(chrom, path_out = tempdir(), force = TRUE)
Exports mass spectrometry data in ANDI (Analytical Data Interchange) MS format (ASTM E1947-98). A total ion chromatogram is derived from the MS1 scans if the supplied object does not already carry one.
write_andi_ms( x, path_out, sample_name = NULL, force = FALSE, ms_params = list() )write_andi_ms( x, path_out, sample_name = NULL, force = FALSE, ms_params = list() )
x |
A list of chromatograms containing an element whose name includes
|
path_out |
The path to write the file. |
sample_name |
The name of the file. If a name is not provided, the name
will be derived from the |
force |
Whether to overwrite existing files at the specified path.
Defaults to |
ms_params |
A list of settings recorded in the file:
|
Retention times are written in seconds, the only time unit the
specification suggests, and declared in raw_data_time_units. A
chromatogram is converted unless its time_unit already reports seconds, so
one whose unit is missing or unrecognized is taken to be in minutes.
Invisibly returns the path to the written CDF file.
Exports mass spectrometry data in ANDI MS format (netCDF) in the directory
specified by path_out. The file will be named according to the value
of sample_name. If no sample_name is provided, the sample_name
attribute will be used if it exists.
Ethan Bass
Other write functions:
write_agilent_amx(),
write_andi_chrom(),
write_chroms(),
write_mzml()
## Not run: write_andi_ms(chrom, path_out = "path/to/directory") ## End(Not run)## Not run: write_andi_ms(chrom, path_out = "path/to/directory") ## End(Not run)
Writes chromatograms to disk in the format specified by export_format:
either mzml, cdf, csv, or arw.
write_chroms( chrom_list, path_out, export_format = c("mzml", "cdf", "csv", "arw"), what = "", force = FALSE, show_progress = TRUE, verbose = getOption("verbose"), ... )write_chroms( chrom_list, path_out, export_format = c("mzml", "cdf", "csv", "arw"), what = "", force = FALSE, show_progress = TRUE, verbose = getOption("verbose"), ... )
chrom_list |
A list of chromatograms. |
path_out |
Path to directory for writing files. |
export_format |
Format to export files: either |
what |
What to write. Used by the |
force |
Logical. Whether to overwrite existing files. Defaults to
|
show_progress |
Logical. Whether to show progress bar. Defaults to |
verbose |
Logical. Whether to print verbose output. |
... |
Additional arguments to write function. |
No return value. The function is called for its side effects.
Exports a chromatogram in the file format specified by export_format in the
directory specified by path_out.
Ethan Bass
Other write functions:
write_agilent_amx(),
write_andi_chrom(),
write_andi_ms(),
write_mzml()
path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") chroms <- read_chroms(path, format_in = "shimadzu_ascii", find_files = FALSE, progress_bar = FALSE) write_chroms(chroms, path_out = tempdir(), export_format = "csv", show_progress = FALSE)path <- system.file("extdata/alkane_ladder.txt", package = "chromConverter") chroms <- read_chroms(path, format_in = "shimadzu_ascii", find_files = FALSE, progress_bar = FALSE) write_chroms(chroms, path_out = tempdir(), export_format = "csv", show_progress = FALSE)
Writes spectra and chromatograms to an mzML file.
write_mzml( data, path_out, sample_name = NULL, what = NULL, instrument_info = NULL, centroided = TRUE, compress = TRUE, indexed = TRUE, force = FALSE, show_progress = TRUE, verbose = getOption("verbose") )write_mzml( data, path_out, sample_name = NULL, what = NULL, instrument_info = NULL, centroided = TRUE, compress = TRUE, indexed = TRUE, force = FALSE, show_progress = TRUE, verbose = getOption("verbose") )
data |
A named list of |
path_out |
The path to write the file. |
sample_name |
The name of the file. If a name is not provided, the name
will be derived from the |
what |
Which streams to write to mzML: |
instrument_info |
Controlled-vocabulary terms describing the
instrument, as a list of lists with elements |
centroided |
Logical. Whether the spectra are centroided, written as
|
compress |
Logical. Whether to use zlib compression. Defaults to |
indexed |
Logical. Whether to write indexed mzML. Defaults to |
force |
Logical. Whether to overwrite existing files at |
show_progress |
Logical. Whether to show progress bar. Defaults to |
verbose |
Logical. Whether or not to print status messages. |
Mass spectra and DAD spectra are written to the spectrumList, while the
total ion current (TIC) and the base peak chromatogram (BPC) go to the
chromatogramList, since the controlled vocabulary has terms for those two
summaries. DAD spectra are written as electromagnetic radiation spectra
(MS:1000804) using Thermo's naming convention, with controllerType=4 in
the spectrum ID for compatibility with existing tools.
Asking for both MS1 and MS2 writes them into one spectrumList,
interleaved in acquisition order: on the scan column they share, or on
retention time where neither has one. Each spectrum is then named for its
scan (scan=417) rather than for its position in the list, which keeps the
names unique across the levels. An MS2 spectrum carries the
precursor it came from as MS:1000744 ("selected ion m/z"), and a
spectrumRef to the MS1 spectrum that precedes it, and its collision energy
as MS:1000045 where it is known, from the scan_info attribute or a
collision_energy (or voltage) column. The isolation window and precursor
charge are not written, as no parser in the package reads them.
MRM scans are written to the chromatogramList instead, as one selected
reaction monitoring chromatogram (MS:1001473) per transition, with its
precursor and product m/z as the targets of their isolation windows, as
'msconvert' writes them. A scan is taken to be MRM where the scan_type
column of the scan_info attribute says so, or, where it records no type,
where the scan holds more than one precursor_mz. Precursor or product m/z
values that lie within 0.005 of the next value up are taken to be the same
transition. Read them back with read_mzml(what = "chroms").
Retention times are written in minutes (UO:0000031), as chromConverter
reports them, rather than converted to seconds as write_andi_ms does.
The streams to write come from the names of data, so a bare chromatogram
has to say what it holds through its detector attribute: UV and DAD
are written as a DAD stream, and MS as MS1, or as MS2 where the table
also carries an ms_level attribute above 1, or a scan_info attribute
whose scans are all above level 1. Any other detector,
including a missing or NA one (which is how several parsers report an
unknown detector), is an error: the function stops rather than guess, and
asks for a named list instead.
A one-dimensional DAD stream (a single wavelength) is refused: mzML has no axis to write it along, so it would become one single-point spectrum per retention time. Use write_andi_chrom for a single trace. If it is the only stream requested this is an error; otherwise it is dropped with a warning and the rest is written.
The file's metadata are taken from the MS1 stream if it is written, and
otherwise from the first stream requested. That stream's sample_name
attribute names the file unless sample_name is supplied.
If indexed = TRUE, the function will generate an indexed mzML file, which
allows faster random access to spectra. The file is assembled by writing XML
strings straight to a connection rather than by building a document in
memory.
Invisibly returns the path to the written mzML file.
Ethan Bass
Other write functions:
write_agilent_amx(),
write_andi_chrom(),
write_andi_ms(),
write_chroms()
## Not run: chrom <- read_chroms("path/to/file.qgd", progress_bar = FALSE) write_mzml(chrom[[1]], path_out = "path/to/directory") ## End(Not run)## Not run: chrom <- read_chroms("path/to/file.qgd", progress_bar = FALSE) write_mzml(chrom[[1]], path_out = "path/to/directory") ## End(Not run)