| Title: | 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>. |
| Authors: | Sebastian Kopf [aut, cre] (ORCID: <https://orcid.org/0000-0002-2044-0201>) |
| Maintainer: | Sebastian Kopf <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 0.6.1 |
| Built: | 2026-07-11 08:01:14 UTC |
| Source: | https://github.com/isoverse/isoreader2 |
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.
Resources:
Website for the isoreader2 package: https://isoreader2.isoverse.org
Package options: ir_options
Maintainer: Sebastian Kopf [email protected] (ORCID)
Authors:
Sebastian Kopf [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/isoverse/isoreader2/issues
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.
auto()auto()
an opaque sentinel of class ir_auto
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.
## S3 method for class 'ir_aggregated_data' c(...)## S3 method for class 'ir_aggregated_data' c(...)
... |
|
a single combined ir_aggregated_data object
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.
## S3 method for class 'ir_isofiles' c(...)## S3 method for class 'ir_isofiles' c(...)
... |
|
a single combined ir_isofiles object
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.
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 )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 )
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 |
a list of merged dataframes collected from the isofiles based on the aggregator definitions
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
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 )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 )
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 |
|
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).
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).
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).
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.
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.
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), ... )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), ... )
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 |
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
ir_check_isosolfs(): ensure the isosolfs helper executable (used
to read Qtegra .imexp notebooks) is installed. Released alongside
isoextract and called automatically by ir_check_isoextract(), so it
rarely needs to be called directly.
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.
ir_convert_intensity( dataset, resistors = NULL, units = c("mV", "V", "fA", "pA", "nA", "µA", "mA", "A", "cps") )ir_convert_intensity( dataset, resistors = NULL, units = c("mV", "V", "fA", "pA", "nA", "µA", "mA", "A", "cps") )
dataset |
a data frame with columns |
resistors |
a data frame with columns |
units |
target unit, one of |
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>.
the dataset with its intensity.* column converted to the target
units and renamed accordingly (e.g. intensity.mV)
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)).
ir_default_theme(text_size = 16)ir_default_theme(text_size = 16)
text_size |
base font size in points (default: |
a ggplot2 theme object
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.
ir_examples_folder() ir_copy_examples(folder = "examples")ir_examples_folder() ir_copy_examples(folder = "examples")
folder |
target directory to copy the example files into (default
|
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
ir_copy_examples(): copy the bundled example files into a local
folder, 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 .json sidecars, so reading from
the copied folder re-extracts them from scratch (requires the isoextract
executable).
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()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()
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").
ir_export_to_excel( ..., file, dbl_digits = 2, int_format = "0", dbl_format = sprintf(sprintf("%%.%sf", dbl_digits), 0), show_progress = is_interactive() )ir_export_to_excel( ..., file, dbl_digits = 2, int_format = "0", dbl_format = sprintf(sprintf("%%.%sf", dbl_digits), 0), show_progress = is_interactive() )
... |
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 |
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.
the exported data invisibly (the single data frame if one was provided, otherwise the list of data frames), for use in pipes
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") ) }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
ir_extract_isofiles( file_paths, pretty_json = FALSE, dry_run = FALSE, show_progress = is_interactive(), show_problems = TRUE ) ir_get_isoextract_version()ir_extract_isofiles( file_paths, pretty_json = FALSE, dry_run = FALSE, show_progress = is_interactive(), show_problems = TRUE ) ir_get_isoextract_version()
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 |
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
ir_get_isoextract_version(): return the version of the installed
isoextract executable as a numeric_version, or
NULL if it is not installed (or does not report a recognizable version)
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.
ir_filter_for_continuous_flow(isofiles) ir_filter_for_dual_inlet(isofiles) ir_filter_for_scans(isofiles)ir_filter_for_continuous_flow(isofiles) ir_filter_for_dual_inlet(isofiles) ir_filter_for_scans(isofiles)
isofiles |
a collection of isofiles from |
Files whose metadata has no type column (e.g. a file that errored during
reading) never match and are dropped.
the isofiles object filtered to the requested measurement type
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")
Finds isodat files with the specified extensions in one or more folders.
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)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)
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 |
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)
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)
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"))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"))
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.
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)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)
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 |
a tibble with the prepared data plus the trace, data_type, and
value columns described above.
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.
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") )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") )
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) |
a tibble
ir_get_metadata(): shortcut for retrieving all metadata columns (i.e. metadata = dplyr::everything())
ir_get_resistors(): shortcut for retrieving all resistors columns (i.e. resistors = dplyr::everything()), keyed by the selected metadata
ir_get_traces(): shortcut for retrieving all traces columns (i.e. traces = dplyr::everything()), keyed by the selected metadata
ir_get_cycles(): shortcut for retrieving all cycles columns (i.e. cycles = dplyr::everything()), keyed by the selected metadata
ir_get_scans(): shortcut for retrieving all scans columns (i.e. scans = dplyr::everything()), keyed by the selected metadata
ir_get_vendor_data_table(): shortcut for retrieving all vendor_data_table columns (i.e. vendor_data_table = dplyr::everything()), keyed by the selected metadata. Only available when aggregated with the "extended" aggregator.
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.
ir_get_problems(obj, strip_ansi = TRUE) ir_show_problems(obj)ir_get_problems(obj, strip_ansi = TRUE) ir_show_problems(obj)
obj |
data object that holds problems information |
strip_ansi |
whether to remove ansi characters from the message, yes by default |
tibble data frame with a list of problems encountered during processing
Get supported file types
ir_get_supported_file_types()ir_get_supported_file_types()
a tibble of the file types supported by this package
ir_get_supported_file_types()ir_get_supported_file_types()
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.
ir_save_isofiles(isofiles, file) ir_load_isofiles(file)ir_save_isofiles(isofiles, file) ir_load_isofiles(file)
isofiles |
a collection of isofiles from |
file |
path to the RDS file ( |
This operates at the unaggregated ir_isofiles level. To store an aggregated
result instead, use ir_save_aggregated_data() / ir_load_aggregated_data().
ir_save_isofiles() returns isofiles invisibly;
ir_load_isofiles() returns an ir_isofiles object.
ir_save_isofiles(): save isofiles to an RDS file
ir_load_isofiles(): load isofiles from an RDS file
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).
ir_filter_metadata(isofiles, ...) ir_mutate_metadata(isofiles, ...) ir_join_metadata(isofiles, y, by)ir_filter_metadata(isofiles, ...) ir_mutate_metadata(isofiles, ...) ir_join_metadata(isofiles, y, by)
isofiles |
datasets aggregated from |
... |
passed to |
y |
data frame to join to the metadata |
by |
character vector of columns to join by (passed to |
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.
the isofiles object (of the same type as the input) with updated metadata
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
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.
ir_options(...) ir_get_options(pattern = NULL) ir_get_option(x)ir_options(...) ir_get_options(pattern = NULL) ir_get_option(x)
... |
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 |
ir_options() and ir_get_options() return a named list of option
values; ir_get_option() returns the value of the single requested option.
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)
aggregators: data aggregators for pulling data out of raw files. The list of available aggregators is accessible via ir_get_option("aggregators"). Individual aggregators are available via the shortcut helper function ir_get_aggregator("standard"). Register new/overwrite existing aggregators via ir_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 call library(isoir). Can be turned off by calling isoir::ir_options(auto_use_ansi = FALSE) before call library(isoir).
# All default options ir_get_options()# All default options ir_get_options()
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.
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, ... )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, ... )
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 |
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.
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.
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, ... )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, ... )
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 |
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.
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.
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, ... )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, ... )
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 |
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
ir_read_isofiles( file_paths, show_progress = is_interactive(), show_problems = TRUE, reextract = FALSE )ir_read_isofiles( file_paths, show_progress = is_interactive(), show_problems = TRUE, reextract = FALSE )
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 |
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()).
c.ir_isofiles() to combine collections of isofiles
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.
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)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)
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 |
an aggregator tibble
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 with ir_get_aggregator()
ir_get_aggregator(): retrieve a registered aggregator (get all aggregators with ir_get_option("aggregators"))
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.
ir_save_aggregated_data(aggregated_data, file) ir_load_aggregated_data(file)ir_save_aggregated_data(aggregated_data, file) ir_load_aggregated_data(file)
aggregated_data |
datasets aggregated from |
file |
path to the parquet file ( |
Requires the suggested arrow package.
ir_save_aggregated_data() returns aggregated_data invisibly;
ir_load_aggregated_data() returns an ir_aggregated_data object.
ir_save_aggregated_data(): save aggregated data to a parquet file
ir_load_aggregated_data(): load aggregated data from a parquet file