| Title: | Read Stable Isotope Data Files |
| Version: | 0.6.1 |
| Description: | Interface to the raw data and metadata stored in the file formats commonly encountered in scientific disciplines that make use of stable isotopes. Supports Isodat (.dxf, .cf, .did, .caf, .scn), IonOS (.iarc), LyticOS (.larc), Callisto (.bch), and Qtegra (.imexp) file formats. Provides a consistent data structure together with tools to aggregate, convert signal units, filter, and visualize the extracted data. The approach is described in Kopf et al. (2021) <doi:10.21105/joss.02878>. |
| License: | AGPL (≥ 3) |
| Encoding: | UTF-8 |
| URL: | https://isoreader2.isoverse.org/, https://github.com/isoverse/isoreader2 |
| BugReports: | https://github.com/isoverse/isoreader2/issues |
| Depends: | R (≥ 4.5.0) |
| Imports: | ggplot2, tools, utils, methods, stats, rlang (≥ 1.1.0), cli (≥ 3.6.0), processx, readr, tibble, dplyr, tidyr, purrr, withr, RcppSimdJson, scales, fansi, knitr |
| Suggests: | testthat (≥ 3.0.0), vdiffr, arrow, openxlsx, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-03 17:58:55 UTC; seko0922 |
| Author: | Sebastian Kopf |
| Maintainer: | Sebastian Kopf <sebastian.kopf@colorado.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-10 20:40:02 UTC |
isoreader2: Read Stable Isotope Data Files
Description
Interface to the raw data and metadata stored in the file formats commonly encountered in scientific disciplines that make use of stable isotopes. Supports Isodat (.dxf, .cf, .did, .caf, .scn), IonOS (.iarc), LyticOS (.larc), Callisto (.bch), and Qtegra (.imexp) file formats. Provides a consistent data structure together with tools to aggregate, convert signal units, filter, and visualize the extracted data. The approach is described in Kopf et al. (2021) doi:10.21105/joss.02878.
Details
Resources:
Website for the isoreader2 package: https://isoreader2.isoverse.org
Package options: ir_options
Author(s)
Maintainer: Sebastian Kopf sebastian.kopf@colorado.edu (ORCID)
Authors:
Sebastian Kopf sebastian.kopf@colorado.edu (ORCID)
See Also
Useful links:
Report bugs at https://github.com/isoverse/isoreader2/issues
Automatic / default behavior
Description
A sentinel that requests automatic behavior for an argument (currently the
data_type_as_facet argument of the plotting functions
ir_plot_continuous_flow(), ir_plot_dual_inlet(), ir_plot_scans()). It is
the default for those arguments; pass TRUE/FALSE to override the automatic
choice.
Usage
auto()
Value
an opaque sentinel of class ir_auto
Combine aggregated isofile data
Description
Combine multiple ir_aggregate_isofiles() results into a single
ir_aggregated_data object by row-binding each of the contained datasets
(metadata, traces, cycles, scans, resistors, vendor_data_table,
problems, ...) with dplyr::bind_rows(). Datasets present in only some of
the objects are combined as well (missing columns are filled with NA). The
file index uidx is re-numbered across the inputs so each file stays uniquely
identified (and its datasets stay correctly linked) in the combined object.
Usage
## S3 method for class 'ir_aggregated_data'
c(...)
Arguments
... |
|
Value
a single combined ir_aggregated_data object
Combine isofiles
Description
Combine multiple collections of isofiles (read by ir_read_isofiles()) into a single ir_isofiles object by row-binding them with dplyr::bind_rows(). This preserves the object structure and type.
Usage
## S3 method for class 'ir_isofiles'
c(...)
Arguments
... |
|
Value
a single combined ir_isofiles object
Aggregate data from isofiles
Description
This function allows dynamic aggregation and validation of data read by ir_read_isofiles(). Like ir_read_isofiles(), it is designed to be fail save by safely catching errors and reporting back on them (see ir_get_problems()). This function should work out of the box for most files without additional modification of the aggregator.
Usage
ir_aggregate_isofiles(
isofiles,
intensity_units = c("mV", "V", "fA", "pA", "nA", "µA", "mA", "A", "cps"),
aggregator = "standard",
show_progress = is_interactive(),
show_problems = TRUE
)
Arguments
isofiles |
the isotope data files/archives read in by |
intensity_units |
target intensity unit to convert traces/cycles/scans to before aggregation,
one of |
aggregator |
typically the name of a registered aggregator (see all with |
show_progress |
whether to show a progress bar, by default always enabled when running interactively e.g. inside Positron or RStudio (and disabled in a notebook), turn off with |
show_problems |
whether to show problems encountered along the way (rather than just keeping track of them with |
Value
a list of merged dataframes collected from the isofiles based on the aggregator definitions
Calculate isotope ratios
Description
Calculate intensity ratios of each mass relative to a base mass for every
measurement in an ir_aggregate_isofiles() result. Ratios are added directly
to the traces (continuous flow), cycles (dual inlet), and/or scans data
present in the aggregated data as two extra columns: ratio_name (e.g.
"29/28") and ratio. The ratio at each time.s/cycle/x position
(within every uidx and analysis) is
Usage
ir_calculate_ratios(
aggregated_data,
...,
num_add.V = 100,
denom_add.V = num_add.V,
num_add.nA = 0,
denom_add.nA = num_add.nA,
num_add.cps = 0,
denom_add.cps = num_add.cps,
normalize_ratios = NULL
)
Arguments
aggregated_data |
datasets aggregated from |
... |
named base masses for individual species, e.g. |
num_add.V, denom_add.V |
additive offset (in volts) for the numerator and
denominator intensities of voltage-unit data ( |
num_add.nA, denom_add.nA |
additive offset (in nanoamperes) for the
numerator and denominator intensities of current-unit data
( |
num_add.cps, denom_add.cps |
additive offset (in cps) for the numerator and
denominator intensities of count-unit data ( |
normalize_ratios |
|
Details
ratio = (I_{mass} + num\_add) / (I_{base} + denom\_add)
i.e. the intensity of the mass divided by the intensity of the base mass of
the same species, after adding an additive offset to numerator and denominator
(see below). Base mass rows are kept and have NA in both columns. Calling
this function again recomputes (overwrites) the ratio_name/ratio columns.
The resulting ratios are not constrained in any way (they can be any value).
The base mass for a species is, by default, the numerically lowest mass
measured for that species. Override it for individual species via ... (e.g.
SO2 = 64, N2 = 28).
Value
the aggregated_data with ratio_name and ratio columns added to
each of the traces, cycles, and/or scans datasets that is present.
Both columns are NA for base mass rows (and for any species whose
requested base mass could not be found).
Additive offsets
The additive offsets apply to continuous-flow (traces) and scans data
only. Dual inlet (cycles) data is not offset and always uses the
plain ratio I_mass / I_base regardless of the num_add.*/denom_add.*
settings.
For traces and scans, which pair of additive offsets is used depends on the
intensity unit family of the data: voltage (V, mV) uses
num_add.V/denom_add.V, current (A, mA, µA, nA, pA, fA) uses
num_add.nA/denom_add.nA, and counts (cps) uses
num_add.cps/denom_add.cps. The offsets are specified in their family's
reference unit (volts, nanoamperes, cps) and are automatically scaled to the
data's actual intensity unit before being added. For example, with
intensity.mV data the default num_add.V = 100 (volts) is multiplied by
1000 and 100000 mV are added; with intensity.pA data the default
num_add.nA = 0 would be multiplied by 1000 (1 nA = 1000 pA).
Normalization
normalize_ratios is NULL by default (no normalization). Pass a function to
divide every ratio by the value that function returns for its
uidx/analysis/ratio_name group (the function receives the group's
non-NA ratios). For example normalize_ratios = mean centers each ratio
around 1, while median, min, or max normalize to the group median,
minimum, or maximum, respectively.
Check for the isoextract executables
Description
By default, these will install the executable if it is missing or outdated.
They run automatically when needed and do not usually need to be called
directly by the user. In particular, ir_check_isoextract() calls
ir_check_isosolfs() automatically (unless check_isosolfs = FALSE), so
ir_check_isosolfs() rarely needs to be called on its own.
Usage
ir_check_isoextract(
install_if_missing = !on_cran(),
reinstall_if_outdated = !on_cran(),
reinstall_always = FALSE,
min_version = "0.3.1",
show_version = TRUE,
ask_permission = TRUE,
source =
paste0("https://github.com/isoverse/IsofileExtractor/releases/download/isoextract-v",
min_version),
check_isosolfs = TRUE,
...
)
ir_check_isosolfs(
install_if_missing = !on_cran(),
reinstall_if_outdated = !on_cran(),
reinstall_always = FALSE,
min_version = "1.0.0",
show_version = TRUE,
ask_permission = TRUE,
source =
paste0("https://github.com/isoverse/IsofileExtractor/releases/download/isosolfs-v",
min_version),
...
)
Arguments
install_if_missing |
install the executable if it's missing |
reinstall_if_outdated |
install the executable if it's outdated (i.e. not at least |
reinstall_always |
whether to (re-)install no matter what |
min_version |
the minimum version number required |
show_version |
whether to print the installed version after
a successful check (default: |
ask_permission |
whether to ask for the user's permission before
downloading a missing or outdated executable (default: |
source |
the URL (or local path) where to find the executable, by default this is the latest release of the executables on github |
check_isosolfs |
whether to also ensure the |
... |
passed on to |
Value
called for its side effect of ensuring a working executable (at least
min_version) is installed — and, for ir_check_isoextract() when
check_isosolfs = TRUE, isosolfs as well; returns NULL invisibly and
aborts if a required executable cannot be made available
Functions
-
ir_check_isosolfs(): ensure theisosolfshelper executable (used to read Qtegra.imexpnotebooks) is installed. Released alongside isoextract and called automatically byir_check_isoextract(), so it rarely needs to be called directly.
Convert intensity between units
Description
Note: this function is rarely called directly, it's run as part of ir_aggregate_isofiles to standardize the trace/cycle/scan datasets before aggregation.
Usage
ir_convert_intensity(
dataset,
resistors = NULL,
units = c("mV", "V", "fA", "pA", "nA", "µA", "mA", "A", "cps")
)
Arguments
dataset |
a data frame with columns |
resistors |
a data frame with columns |
units |
target unit, one of |
Details
Converts the intensity column of a dataset between voltage, current, and
count-per-second units using A = CPS * e and V = A * R. Automatically
detects the source unit from any intensity.<unit> column present in
dataset. Joins resistors by species and channel (plus config when
present in both) only when the conversion path crosses the A/V boundary.
Returns dataset with the source intensity column replaced by
intensity.<units>.
Value
the dataset with its intensity.* column converted to the target
units and renamed accordingly (e.g. intensity.mV)
Default isoreader2 plotting theme
Description
This theme is always applied by the plotting functions
(ir_plot_continuous_flow(), ir_plot_dual_inlet(), ir_plot_scans()).
To customize a plot, add a ggplot2::theme() on top of the returned plot,
e.g. ir_plot_continuous_flow(...) + ggplot2::theme(text = element_text(size = 20)).
Usage
ir_default_theme(text_size = 16)
Arguments
text_size |
base font size in points (default: |
Value
a ggplot2 theme object
Bundled example files
Description
ir_examples_folder() returns the path to the folder with the
example isodat files bundled with the package (a convenience wrapper around
system.file("extdata", package = "isoreader2")). ir_copy_examples()
copies those example files into a local folder so they can be read,
re-extracted, or modified without touching the read-only package
installation.
Usage
ir_examples_folder()
ir_copy_examples(folder = "examples")
Arguments
folder |
target directory to copy the example files into (default
|
Value
ir_examples_folder() returns the path to the example files folder as
a single string.
ir_copy_examples() invisibly returns the path to the created examples folder
Functions
-
ir_copy_examples(): copy the bundled example files into a localfolder, creating it if necessary and only copying files that do not already exist there (existing files are left untouched). Only the original data files are copied, not their bundled.jsonsidecars, so reading from the copied folder re-extracts them from scratch (requires the isoextract executable).
Examples
ir_examples_folder() |> ir_find_scans()
# copy the bundled examples into a temporary folder and find them
ir_copy_examples(folder = file.path(tempdir(), "examples")) |>
ir_find_continuous_flow()
Export data to Excel
Description
Exports one or more data frames / tibbles (typically retrieved with the
ir_get_*() functions, e.g. ir_get_metadata(), ir_get_traces()) to an
Excel file, one sheet per data frame. Pass the data frames as ...: named
arguments use the name as the sheet name, unnamed arguments are placed in
a sheet named after their position (e.g. the 3rd unnamed data frame goes into
"Sheet3").
Usage
ir_export_to_excel(
...,
file,
dbl_digits = 2,
int_format = "0",
dbl_format = sprintf(sprintf("%%.%sf", dbl_digits), 0),
show_progress = is_interactive()
)
Arguments
... |
one or more data frames / tibbles to export, one per sheet. Named
arguments set the sheet name; unnamed arguments use |
file |
path to the |
dbl_digits |
number of decimal places shown for double columns (all digits are stored; this only affects display formatting in Excel) |
int_format |
Excel number format string for integer columns |
dbl_format |
Excel number format string for double columns (derived
automatically from |
show_progress |
whether to show a progress indicator |
Details
This function only accepts data frames. To store a complete
ir_aggregate_isofiles() result use ir_save_aggregated_data() instead.
Requires the suggested openxlsx package.
Value
the exported data invisibly (the single data frame if one was provided, otherwise the list of data frames), for use in pipes
Examples
if (requireNamespace("openxlsx", quietly = TRUE)) {
agg <- ir_examples_folder() |>
ir_find_continuous_flow() |>
ir_read_isofiles() |>
ir_aggregate_isofiles()
ir_export_to_excel(
metadata = ir_get_metadata(agg),
traces = ir_get_traces(agg),
file = file.path(tempdir(), "my_export.xlsx")
)
}
run the isoextract executable on a vector of file paths this is usually not called directly
Description
run the isoextract executable on a vector of file paths this is usually not called directly
Usage
ir_extract_isofiles(
file_paths,
pretty_json = FALSE,
dry_run = FALSE,
show_progress = is_interactive(),
show_problems = TRUE
)
ir_get_isoextract_version()
Arguments
file_paths |
paths to the isodat file(s), single value or vector of paths. Use |
pretty_json |
whether to write the JSON output in human-readable
pretty-printed format (default: |
dry_run |
whether to run isoextract in "dry run" mode (default: |
show_progress |
whether to show a progress bar, by default always enabled when running interactively e.g. inside Positron or RStudio (and disabled in a notebook), turn off with |
show_problems |
whether to show problems encountered along the way (rather than just keeping track of them with |
Value
called for its side effect of running isoextract to write a .json
sidecar file next to each input file (unless dry_run = TRUE); returns
NULL invisibly
Functions
-
ir_get_isoextract_version(): return the version of the installedisoextractexecutable as a numeric_version, orNULLif it is not installed (or does not report a recognizable version)
Filter isofiles by measurement type
Description
Convenience wrappers around ir_filter_metadata() that keep only the files of
a single measurement type (using the metadata type column): continuous flow
("cf"), dual inlet ("di"), or scan ("scan"). Like ir_filter_metadata()
they work on both ir_isofiles (from ir_read_isofiles()) and
ir_aggregated_data (from ir_aggregate_isofiles()) objects, cascade to the
other datasets, and drop any file whose metadata ends up empty.
Usage
ir_filter_for_continuous_flow(isofiles)
ir_filter_for_dual_inlet(isofiles)
ir_filter_for_scans(isofiles)
Arguments
isofiles |
a collection of isofiles from |
Details
Files whose metadata has no type column (e.g. a file that errored during
reading) never match and are dropped.
Value
the isofiles object filtered to the requested measurement type
Functions
-
ir_filter_for_continuous_flow(): keep only continuous flow files (type == "cf") -
ir_filter_for_dual_inlet(): keep only dual inlet files (type == "di") -
ir_filter_for_scans(): keep only scan files (type == "scan")
Find isodat files
Description
Finds isodat files with the specified extensions in one or more folders.
Usage
ir_find_isofiles(
folder,
types = c("dxf", "cf", "iarc", "larc", "bch", "imexp", "caf", "did", "scn"),
pattern = NULL,
recursive = TRUE
)
ir_find_continuous_flow(folder, pattern = NULL, recursive = TRUE)
ir_find_dual_inlet(folder, pattern = NULL, recursive = TRUE)
ir_find_scans(folder, pattern = NULL, recursive = TRUE)
Arguments
folder |
path to a folder with isodat files, or a character vector of folder paths |
types |
file extensions to include (without leading dot), default is all supported types: |
pattern |
provide a name pattern to find only specific files |
recursive |
whether to find files recursively |
Value
a sorted character vector of unique paths that correspond to the original data files (without .json suffixes if those are the versions of the files that are present)
Functions
-
ir_find_continuous_flow(): finds continuous flow files (.dxf,.cf) -
ir_find_dual_inlet(): finds dual inlet files (.did,.caf) -
ir_find_scans(): finds scan files (.scn)
Examples
ir_find_continuous_flow(system.file("extdata", package = "isoreader2"))
ir_find_dual_inlet(system.file("extdata", package = "isoreader2"))
ir_find_scans(system.file("extdata", package = "isoreader2"))
Generate the tibble used by the plotting functions
Description
These helpers build the exact flat tibble that ir_plot_continuous_flow()
(ir_generate_traces_tibble()), ir_plot_dual_inlet()
(ir_generate_cycles_tibble()), and ir_plot_scans()
(ir_generate_scans_tibble()) plot, so it can be inspected or used
independently of producing a plot. The dataset is prepared exactly as for
the plotting functions (an ir_aggregated_data object has its traces /
cycles / scans dataset inner-joined with $metadata; a plain data frame
is used as is), filtered by species, and then split into intensity rows and
(optionally) ratio rows, each augmented with three columns:
-
trace- the identifier"<species>: <mass>"for intensity rows (e.g."CO2: 44") or"<species>: <ratio_name>"for ratio rows (e.g."CO2: 45/44"), always (re)generated and returned as a factor sorted by species and numerical (numerator) mass. -
data_type-"intensity [UNITS]"(e.g."intensity [mV]") for the intensity rows, or"ratios"for ratio rows. -
value- the value to plot: the intensity for intensity rows, or the (optionally fold-clamped) ratio for ratio rows.
Usage
ir_generate_traces_tibble(dataset, species = NULL, mass = NULL, ratio = NULL)
ir_generate_cycles_tibble(dataset, species = NULL, mass = NULL, ratio = NULL)
ir_generate_scans_tibble(dataset, species = NULL, mass = NULL, ratio = NULL)
Arguments
dataset |
an |
species |
optional vector to filter to specific species (e.g. |
mass |
which masses to include as intensity traces: |
ratio |
which ratios to include (computed with |
Value
a tibble with the prepared data plus the trace, data_type, and
value columns described above.
Get data frame from aggregated data
Description
Retrieve a specific subset of the aggregated data into a single data frame by specifying which columns to take from each dataset (metadata, traces, cycles, scans, resistors, vendor_data_table) using dplyr::select() syntax.
If data from more than one dataset is selected (e.g. some columns from traces AND some from resistors), the datasets are combined with an dplyr::inner_join() using the columns listed in by (only the ones actually in the datasets). Joins that would lead to duplicated data entries (i.e. many-to-many joins) are not allowed and will throw an error to avoid unexpected replications of individual datapoints. If you really want to do such a join, you'll have to do it manually.
Usage
ir_get_data(
aggregated_data,
metadata = c("file_name"),
traces = NULL,
cycles = NULL,
scans = NULL,
resistors = NULL,
vendor_data_table = NULL,
by = c("uidx", "analysis", "config", "species", "channel", "mass")
)
ir_get_metadata(aggregated_data, metadata = everything())
ir_get_resistors(
aggregated_data,
metadata = c("file_name"),
by = c("uidx", "analysis")
)
ir_get_traces(
aggregated_data,
metadata = c("file_name"),
by = c("uidx", "analysis")
)
ir_get_cycles(
aggregated_data,
metadata = c("file_name"),
by = c("uidx", "analysis")
)
ir_get_scans(
aggregated_data,
metadata = c("file_name"),
by = c("uidx", "config")
)
ir_get_vendor_data_table(
aggregated_data,
metadata = c("file_name"),
by = c("uidx", "analysis")
)
Arguments
aggregated_data |
datasets aggregated from |
metadata |
columns to get from the aggregated |
traces |
columns to get from the aggregated |
cycles |
columns to get from the aggregated |
scans |
columns to get from the aggregated |
resistors |
columns to get from the aggregated |
vendor_data_table |
columns to get from the aggregated |
by |
character vector of column names used as join keys when combining data from more than one dataset (default covers the standard linking columns; only keys actually present in both datasets are used) |
Value
a tibble
Functions
-
ir_get_metadata(): shortcut for retrieving allmetadatacolumns (i.e.metadata = dplyr::everything()) -
ir_get_resistors(): shortcut for retrieving allresistorscolumns (i.e.resistors = dplyr::everything()), keyed by the selectedmetadata -
ir_get_traces(): shortcut for retrieving alltracescolumns (i.e.traces = dplyr::everything()), keyed by the selectedmetadata -
ir_get_cycles(): shortcut for retrieving allcyclescolumns (i.e.cycles = dplyr::everything()), keyed by the selectedmetadata -
ir_get_scans(): shortcut for retrieving allscanscolumns (i.e.scans = dplyr::everything()), keyed by the selectedmetadata -
ir_get_vendor_data_table(): shortcut for retrieving allvendor_data_tablecolumns (i.e.vendor_data_table = dplyr::everything()), keyed by the selectedmetadata. Only available when aggregated with the"extended"aggregator.
Retrieve parsing problems
Description
This function retrieves parsing problems encountered during the reading and processing of files.
This function prints out parsing problems encountered during the reading and processing of files.
Usage
ir_get_problems(obj, strip_ansi = TRUE)
ir_show_problems(obj)
Arguments
obj |
data object that holds problems information |
strip_ansi |
whether to remove ansi characters from the message, yes by default |
Value
tibble data frame with a list of problems encountered during processing
Get supported file types
Description
Get supported file types
Usage
ir_get_supported_file_types()
Value
a tibble of the file types supported by this package
Examples
ir_get_supported_file_types()
Save and load isofiles
Description
ir_save_isofiles() serializes a collection of isofiles read with
ir_read_isofiles() to an RDS file using readr::write_rds(), storing the
whole ir_isofiles object as-is (including all nested datasets and condition
objects) without any changes. ir_load_isofiles() reads the file back with
readr::read_rds() and returns the ir_isofiles object exactly as it was
saved.
Usage
ir_save_isofiles(isofiles, file)
ir_load_isofiles(file)
Arguments
isofiles |
a collection of isofiles from |
file |
path to the RDS file ( |
Details
This operates at the unaggregated ir_isofiles level. To store an aggregated
result instead, use ir_save_aggregated_data() / ir_load_aggregated_data().
Value
ir_save_isofiles() returns isofiles invisibly;
ir_load_isofiles() returns an ir_isofiles object.
Functions
-
ir_save_isofiles(): save isofiles to an RDS file -
ir_load_isofiles(): load isofiles from an RDS file
Filter, mutate, or join the metadata of isofiles
Description
These functions modify the metadata of either an ir_aggregate_isofiles()
result (ir_aggregated_data) or a collection of isofiles read with
ir_read_isofiles() (ir_isofiles).
Usage
ir_filter_metadata(isofiles, ...)
ir_mutate_metadata(isofiles, ...)
ir_join_metadata(isofiles, y, by)
Arguments
isofiles |
datasets aggregated from |
... |
passed to |
y |
data frame to join to the metadata |
by |
character vector of columns to join by (passed to |
Details
For ir_aggregated_data, the operation is applied once to the combined
$metadata data frame. For ir_filter_metadata(), the filter then cascades
to all other datasets: traces, cycles, and scans are filtered by the
remaining uidx + analysis combinations; resistors and problems are
filtered by the remaining uidx values.
For ir_isofiles, the same operation is instead applied individually to
each row (i.e. to each file's own nested datasets), since an ir_isofiles
object has no combined metadata to operate on. Within each row, the filter
cascade uses whichever linking columns are present (typically analysis).
For ir_filter_metadata(), any file whose metadata ends up with 0 rows after
the filter is removed from the ir_isofiles collection entirely.
Operating on an unaggregated ir_isofiles object is supported for convenience,
but is significantly slower than operating on an ir_aggregated_data
result, because the operation has to be carried out separately on every file
rather than once on the combined metadata. For anything beyond small
collections, prefer aggregating first with ir_aggregate_isofiles() and then
applying these functions to the result.
After filtering, columns that are entirely NA across all remaining rows are
dropped from every (non-empty) dataset.
All three functions also clear the not-aggregated column information (columns
present in the source files but not included in the aggregator) from every
dataset, since that information is no longer meaningful after the metadata has
been modified.
Value
the isofiles object (of the same type as the input) with updated metadata
Functions
-
ir_filter_metadata(): filter rows of the metadata (and cascade to the other datasets) -
ir_mutate_metadata(): add or modify columns in the metadata -
ir_join_metadata(): left-join additional columns into the metadata
Package options
Description
These options are best set via ir_options() and queried via ir_get_option().
However, the base functions options() and getOption() work as well but require
an isoreader2. prefix (the package name and a dot) for the option name. Setting
an option to a value of NULL means that the default is used. ir_get_options()
is available as an additional convenience function to retrieve a subset of options
with a regular expression pattern.
Usage
ir_options(...)
ir_get_options(pattern = NULL)
ir_get_option(x)
Arguments
... |
set package options, syntax identical to |
pattern |
to retrieve multiple options (as a list) with a shared pattern |
x |
name of the specific option to retrieve |
Value
ir_options() and ir_get_options() return a named list of option
values; ir_get_option() returns the value of the single requested option.
Functions
-
ir_options(): set/get option values -
ir_get_options(): get a subset of option values that fit a pattern -
ir_get_option(): retrieve the current value of one option (option must be defined for the package)
Options for the isoreader2 package
-
aggregators: data aggregators for pulling data out of raw files. The list of available aggregators is accessible viair_get_option("aggregators"). Individual aggregators are available via the shortcut helper functionir_get_aggregator("standard"). Register new/overwrite existing aggregators viair_register_aggregator(). -
debug: turn on debug mode -
auto_use_ansi: whether to automatically enable correct rendering of stylized (ansi) output in HTML reports from notebooks that calllibrary(isoir). Can be turned off by callingisoir::ir_options(auto_use_ansi = FALSE)before calllibrary(isoir).
Examples
# All default options
ir_get_options()
Plot continuous flow data
Description
Plots chromatographic trace data from an ir_aggregate_isofiles() result or
a plain data frame. The data is prepared with ir_generate_traces_tibble()
(which, for an ir_aggregated_data object, inner-joins the $traces dataset
with $metadata). The plot data must contain species, time.s, mass, and
an intensity.* column — an error is thrown if any are missing. A trace
identifier ("<species>: <mass>") is always regenerated and the plotted
value together with a data_type label ("intensity [UNITS]", or
"ratios" for ratio rows) are added.
Usage
ir_plot_continuous_flow(
dataset,
species = NULL,
mass = NULL,
ratio = NULL,
facet = NULL,
data_type_as_facet = auto(),
scales = "free",
nrow = NULL,
ncol = 1,
color = trace,
linetype = NULL,
color_values = palette.colors(),
drop_unused_levels = FALSE,
scientific = FALSE,
time_window.s = if (is.null(time_window.min)) NULL else 60 * time_window.min,
time_window.min = NULL,
short_time_labels = FALSE,
n_time_breaks = 5,
n_y_breaks = 5,
...
)
Arguments
dataset |
an |
species |
optional vector to filter the displayed data to specific
species (e.g. |
mass |
which masses to include as intensity traces: |
ratio |
which ratios to additionally include (computed with
|
facet |
column or expression to facet by (default: |
data_type_as_facet |
whether the |
scales |
whether facet scales should be |
nrow, ncol |
number of rows and columns of facet panels ( |
color |
column or expression for the colour aesthetic (default:
|
linetype |
column or expression for the linetype aesthetic (default:
|
color_values |
named or unnamed character vector of colours passed to
|
drop_unused_levels |
whether to drop unused |
scientific |
whether to format y axis labels in scientific notation
(default: |
time_window.s, time_window.min |
optional numeric vector of length 2
giving the time axis display window |
short_time_labels |
whether to use compact time axis labels with no
space between value and unit and abbreviated units ( |
n_time_breaks |
desired number of time axis tick marks (default: |
n_y_breaks |
desired number of y axis tick marks (default: |
... |
additional arguments passed on to |
Value
a ggplot object with ir_default_theme() applied. To customize the
plot, add ggplot2 layers on top (e.g. + ggplot2::theme(...) or
+ ggplot2::labs(...)); attach ggplot2 with library(ggplot2) first.
Plot dual inlet cycle data
Description
Plots cycle data from an ir_aggregate_isofiles() result or a plain data
frame. The data is prepared with ir_generate_cycles_tibble() (which, for an
ir_aggregated_data object, inner-joins the $cycles dataset with
$metadata). The plot data must contain species, cycle, type, mass,
and an intensity.* column — an error is thrown if any are missing. A trace
identifier ("<species>: <mass>") is always regenerated and the plotted
value together with a data_type label ("intensity [UNITS]", or
"ratios" for ratio rows) are added.
Usage
ir_plot_dual_inlet(
dataset,
species = NULL,
mass = NULL,
ratio = NULL,
facet = NULL,
data_type_as_facet = auto(),
scales = "free",
nrow = NULL,
ncol = 1,
color = trace,
shape = type,
linetype = NULL,
color_values = palette.colors(),
drop_unused_levels = FALSE,
scientific = FALSE,
cycle_window = NULL,
n_y_breaks = 5,
...
)
Arguments
dataset |
an |
species |
optional vector to filter the displayed data to specific
species (e.g. |
mass |
which masses to include as intensity traces: |
ratio |
which ratios to additionally include (computed with
|
facet |
column or expression to facet by (default: |
data_type_as_facet |
whether the |
scales |
whether facet scales should be |
nrow, ncol |
number of rows and columns of facet panels ( |
color |
column or expression for the colour aesthetic (default:
|
shape |
column or expression for the point shape aesthetic (default:
|
linetype |
column or expression for the linetype aesthetic (default:
|
color_values |
named or unnamed character vector of colours passed to
|
drop_unused_levels |
whether to drop unused |
scientific |
whether to format y axis labels in scientific notation
(default: |
cycle_window |
optional numeric vector of length 2 giving the cycle axis
display window |
n_y_breaks |
desired number of y axis tick marks (default: |
... |
additional arguments passed on to |
Value
a ggplot object with ir_default_theme() applied. To customize the
plot, add ggplot2 layers on top (e.g. + ggplot2::theme(...) or
+ ggplot2::labs(...)); attach ggplot2 with library(ggplot2) first.
Plot scan data
Description
Plots scan data from an ir_aggregate_isofiles() result or a plain data
frame. The data is prepared with ir_generate_scans_tibble() (which, for an
ir_aggregated_data object, inner-joins the $scans dataset with
$metadata). The plot data must contain species, x, scan_type,
x_units, mass, and an intensity.* column — an error is thrown if any are
missing. A trace identifier ("<species>: <mass>") is always regenerated
and the plotted value together with a data_type label ("intensity [UNITS]", or "ratios" for ratio rows) are added. scan_type and x_units
are combined for the x axis label.
Usage
ir_plot_scans(
dataset,
scan_type = NULL,
species = NULL,
mass = NULL,
ratio = NULL,
facet = NULL,
data_type_as_facet = auto(),
scales = "free",
nrow = NULL,
ncol = 1,
color = trace,
linetype = NULL,
color_values = palette.colors(),
drop_unused_levels = FALSE,
scientific = FALSE,
x_window = NULL,
n_x_breaks = 5,
n_y_breaks = 5,
...
)
Arguments
dataset |
an |
scan_type |
which scan type to plot (e.g. |
species |
optional vector to filter the displayed data to specific
species (e.g. |
mass |
which masses to include as intensity traces: |
ratio |
which ratios to additionally include (computed with
|
facet |
column or expression to facet by (default: |
data_type_as_facet |
whether the |
scales |
whether facet scales should be |
nrow, ncol |
number of rows and columns of facet panels ( |
color |
column or expression for the colour aesthetic (default:
|
linetype |
column or expression for the linetype aesthetic (default:
|
color_values |
named or unnamed character vector of colours passed to
|
drop_unused_levels |
whether to drop unused |
scientific |
whether to format y axis labels in scientific notation
(default: |
x_window |
optional numeric vector of length 2 giving the x axis
display window |
n_x_breaks |
desired number of x axis tick marks (default: |
n_y_breaks |
desired number of y axis tick marks (default: |
... |
additional arguments passed on to |
Value
a ggplot object with ir_default_theme() applied. To customize the
plot, add ggplot2 layers on top (e.g. + ggplot2::theme(...) or
+ ggplot2::labs(...)); attach ggplot2 with library(ggplot2) first.
Read isotope data files
Description
Read isotope data files
Usage
ir_read_isofiles(
file_paths,
show_progress = is_interactive(),
show_problems = TRUE,
reextract = FALSE
)
Arguments
file_paths |
paths to the isodat file(s), single value or vector of paths. Use |
show_progress |
whether to show a progress bar, by default always enabled when running interactively e.g. inside Positron or RStudio (and disabled in a notebook), turn off with |
show_problems |
whether to show problems encountered along the way (rather than just keeping track of them with |
reextract |
whether to re-extract files (uses isoextract to read files
from scratch); if |
Value
a tibble data frame (an ir_isofiles object) where each row holds the file path and nested tibbles of datasets extracted from the isodat files. Use ir_aggregate_isofiles() to aggregate data safely across files. Multiple such collections can be combined into one with a simple c() (see c.ir_isofiles()).
See Also
c.ir_isofiles() to combine collections of isofiles
Dynamic data aggregator
Description
These functions allow definition of custom data aggregators for processing data extracted from isofiles. An aggregator is run on each imported file and pulls together the relevant data users are interested in while making sure data formats are correct so that the aggregated data can be merged across several imported files for fast downstream processing.
Usage
ir_start_aggregator(name)
ir_add_to_aggregator(
aggregator,
dataset = c("metadata", "traces", "cycles", "scans", "resistors", "vendor_data_table"),
column,
source = column,
default = NA,
cast = "as.character",
regexp = FALSE,
func = NULL,
args = NULL
)
ir_register_aggregator(aggregator, name = attr(aggregator, "name"))
ir_get_aggregator(name)
Arguments
name |
a descriptive name for the aggregator. This name is automatically used as the default name when registering the aggregator via |
aggregator |
the aggregator table generated by |
dataset |
the name of the dataset to aggregate from, by default "metadata" which is by far the most common aggregator to work with |
column |
the name of the column in which data should be stored |
source |
single character column name or vector of column names (if alternatives could be the source) where in the |
default |
the default value if no |
cast |
what to cast the values of the resulting column to, most commonly |
regexp |
whether source column names should be interpreted as a regular expressions for the purpose of finding the relevant column(s). Note if |
func |
name of a processing function to apply before casting the value with the |
args |
an optional list of arguments to pass to the |
Value
an aggregator tibble
Functions
-
ir_start_aggregator(): starts the aggregator -
ir_add_to_aggregator(): add additional column to aggregate data for. Overwrites an existing aggregator entry for the same dataset and column if it already exists. -
ir_register_aggregator(): register an aggregator in the isoreader2 options so it can be retrieved withir_get_aggregator() -
ir_get_aggregator(): retrieve a registered aggregator (get all aggregators withir_get_option("aggregators"))
Save and load aggregated isofile data
Description
ir_save_aggregated_data() serializes an ir_aggregate_isofiles() result to a parquet file.
Empty datasets (no columns) are dropped. The condition column of problems
is set to NULL per row because R condition objects cannot be stored in parquet.
ir_load_aggregated_data() reads the file back and returns an ir_aggregated_data object.
Usage
ir_save_aggregated_data(aggregated_data, file)
ir_load_aggregated_data(file)
Arguments
aggregated_data |
datasets aggregated from |
file |
path to the parquet file ( |
Details
Requires the suggested arrow package.
Value
ir_save_aggregated_data() returns aggregated_data invisibly;
ir_load_aggregated_data() returns an ir_aggregated_data object.
Functions
-
ir_save_aggregated_data(): save aggregated data to a parquet file -
ir_load_aggregated_data(): load aggregated data from a parquet file