Title: | Process Orbitrap Isotopocule Data |
---|---|
Description: | Read and process isotopocule data from an Orbitrap Isotope Solutions mass spectrometer. Citation: Kantnerova et al. (Nature Protocols, 2024). |
Authors: | Caj Neubauer [aut, cre, cph] , Sebastian Kopf [aut] , Kristýna Kantnerová [aut] |
Maintainer: | Caj Neubauer <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3.1 |
Built: | 2024-11-12 04:41:59 UTC |
Source: | https://github.com/isoverse/isoorbi |
This function can be used to add colored background to a plot of dual-inlet data where different colors signify different data types (data, startup time, changeover time, unused). Note that this function only works with continuous and pseudo-log y axis, not with log y axes.
orbi_add_blocks_to_plot( plot, x = c("guess", "scan.no", "time.min"), data_only = FALSE, fill = .data$data_type, fill_colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), fill_scale = scale_fill_manual("blocks", values = fill_colors), alpha = 0.5, show.legend = !data_only )
orbi_add_blocks_to_plot( plot, x = c("guess", "scan.no", "time.min"), data_only = FALSE, fill = .data$data_type, fill_colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), fill_scale = scale_fill_manual("blocks", values = fill_colors), alpha = 0.5, show.legend = !data_only )
plot |
object with a dataset that has defined blocks |
x |
which x-axis to use (time vs. scan number). If set to "guess" (the default), the function will try to figure it out from the plot. |
data_only |
if set to TRUE, only the blocks flagged as "data" ( |
fill |
what to use for the fill aesthetic, default is the block |
fill_colors |
which colors to use, by default a color-blind friendly color palettes (RColorBrewer, dark2) |
fill_scale |
use this parameter to replace the entire fill scale rather than just the |
alpha |
opacity settings for the background |
show.legend |
whether to include the background information in the legend |
This function can be used to manually adjust where certain block
starts or ends using either time or scan number.
Note that adjusting blocks removes all block segmentation. Make sure to call orbi_segment_blocks()
after adjusting block delimiters.
orbi_adjust_block( dataset, block, filename = NULL, shift_start_time.min = NULL, shift_end_time.min = NULL, shift_start_scan.no = NULL, shift_end_scan.no = NULL, set_start_time.min = NULL, set_end_time.min = NULL, set_start_scan.no = NULL, set_end_scan.no = NULL )
orbi_adjust_block( dataset, block, filename = NULL, shift_start_time.min = NULL, shift_end_time.min = NULL, shift_start_scan.no = NULL, shift_end_scan.no = NULL, set_start_time.min = NULL, set_end_time.min = NULL, set_start_scan.no = NULL, set_end_scan.no = NULL )
dataset |
tibble produced by |
block |
the block for which to adjust the start and/or end |
filename |
needs to be specified only if the |
shift_start_time.min |
if provided, the start time of the block will be shifted by this many minutes (use negative numbers to shift back) |
shift_end_time.min |
if provided, the end time of the block will be shifted by this many minutes (use negative numbers to shift back) |
shift_start_scan.no |
if provided, the start of the block will be shifted by this many scans (use negative numbers to shift back) |
shift_end_scan.no |
if provided, the end of the block will be shifted by this many scans (use negative numbers to shift back) |
set_start_time.min |
if provided, sets the start time of the block as close as possible to this time |
set_end_time.min |
if provided, sets the end time of the block as close as possible to this time |
set_start_scan.no |
if provided, sets the start of the block to this scan number (scan must exist in the |
set_end_scan.no |
if provided, sets the end of the block to this scan number (scan must exist in the |
A data frame (tibble) with block limits altered according to the provided start/end change parameters. Any data that is no longer part of the original block will be marked with the value of orbi_get_settings("data_type_unused")
. Any previously applied segmentation will be discarded (segment
column set to NA
) to avoid unintended side effects.
This function computes the shot noise calculation.
orbi_analyze_shot_noise(dataset, include_flagged_data = FALSE)
orbi_analyze_shot_noise(dataset, include_flagged_data = FALSE)
dataset |
a data frame output after running |
include_flagged_data |
whether to include flagged data in the shot noise calculation (FALSE by default) |
Analyze shot noise
will calculate for all combinations of filename
, compound
, and isotopocule
in the provided dataset
The processed data frame with new columns: n_effective_ions
, ratio
, ratio_rel_se.permil
, shot_noise.permil
This function calculates isotopocule/base peak ratios for all isotopocules. It does not summarize or average the ratios in any way. For a summarizing version of this function, see orbi_summarize_results()
.
orbi_calculate_ratios(dataset)
orbi_calculate_ratios(dataset)
dataset |
A data frame output after running |
Returns a mutated dataset with ratio
column added.
This function calculates the ratio of two isotopocules (the numerator
and denominator
). This function averages multiple measurements of each using the ratio_method
and returns a single value. Normally this function is not called directly by the user, but via the function orbi_summarize_results()
, which calculates isotopocule ratios and other results for an entire dataset.
orbi_calculate_summarized_ratio( numerator, denominator, ratio_method = c("direct", "mean", "sum", "median", "geometric_mean", "slope", "weighted_sum") )
orbi_calculate_summarized_ratio( numerator, denominator, ratio_method = c("direct", "mean", "sum", "median", "geometric_mean", "slope", "weighted_sum") )
numerator |
Column(s) used as numerator; contains ion counts |
denominator |
Column used as denominator; contains ion counts |
ratio_method |
Method for computing the ratio. Please note well: the formula used to calculate ion ratios matters! Do not simply use arithmetic mean. The best option may depend on the type of data you are processing (e.g., MS1 versus M+1 fragmentation).
|
Single value ratio between the isotopocules defined as numerator
and denominator
calculated using the ratio_method
.
df <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") |> orbi_read_isox() ions_18O <- dplyr::filter(df, isotopocule == "18O")$ions.incremental ions_M0 <- dplyr::filter(df, isotopocule == "M0")$ions.incremental orbi_calculate_summarized_ratio( numerator = ions_18O, denominator = ions_M0, ratio_method = "sum" ) orbi_calculate_summarized_ratio( numerator = ions_18O, denominator = ions_M0, ratio_method = "slope" )
df <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") |> orbi_read_isox() ions_18O <- dplyr::filter(df, isotopocule == "18O")$ions.incremental ions_M0 <- dplyr::filter(df, isotopocule == "M0")$ions.incremental orbi_calculate_summarized_ratio( numerator = ions_18O, denominator = ions_M0, ratio_method = "sum" ) orbi_calculate_summarized_ratio( numerator = ions_18O, denominator = ions_M0, ratio_method = "slope" )
Default isoorbi plotting theme
orbi_default_theme(text_size = 16, facet_text_size = 20)
orbi_default_theme(text_size = 16, facet_text_size = 20)
text_size |
a font size for text |
facet_text_size |
a font size for facet text |
ggplot theme object
orbi_define_basepeak()
sets one isotopocule in the data frame as the base peak (ratio denominator) and calculates the instantaneous isotope ratios against it.
orbi_define_basepeak(dataset, basepeak_def)
orbi_define_basepeak(dataset, basepeak_def)
dataset |
A tibble from a |
basepeak_def |
The isotopocule that gets defined as base peak, i.e. the denominator to calculate ratios |
Input data frame without the rows of the basepeak isotopocule and instead three new columns called basepeak
, basepeak_ions
, and ratio
holding the basepeak information and the isotope ratios vs. the base peak
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_define_basepeak(basepeak_def = "M0")
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_define_basepeak(basepeak_def = "M0")
Define a data block by either start and end time or start and end scan number.
If you want to make segments in the blocks (optional), note that this function - manually defining blocks - removes all block segmentation. Make sure to call orbi_segment_blocks()
only after finishing block definitions.
orbi_define_block_for_flow_injection( dataset, start_time.min = NULL, end_time.min = NULL, start_scan.no = NULL, end_scan.no = NULL, sample_name = NULL )
orbi_define_block_for_flow_injection( dataset, start_time.min = NULL, end_time.min = NULL, start_scan.no = NULL, end_scan.no = NULL, sample_name = NULL )
dataset |
tibble with Orbitrap data |
start_time.min |
set the start time of the block |
end_time.min |
set the end time of the block |
start_scan.no |
set the start scan of the block |
end_scan.no |
set the end scan of the block |
sample_name |
if provided, will be used as the |
A data frame (tibble) with block definition added. Any data that is not part of a block will be marked with the value of orbi_get_settings("data_type_unused")
. Any previously applied segmentation will be discarded (segment
column set to NA
) to avoid unintended side effects.
This function sorts out (bins) data into indivual blocks of reference, sample, changeover time, and startup time.
orbi_define_blocks_for_dual_inlet( dataset, ref_block_time.min, change_over_time.min, sample_block_time.min = ref_block_time.min, startup_time.min = 0, ref_block_name = setting("di_ref_name"), sample_block_name = setting("di_sample_name") )
orbi_define_blocks_for_dual_inlet( dataset, ref_block_time.min, change_over_time.min, sample_block_time.min = ref_block_time.min, startup_time.min = 0, ref_block_name = setting("di_ref_name"), sample_block_name = setting("di_sample_name") )
dataset |
A data frame or tibble produced from IsoX data by |
ref_block_time.min |
time where the signal is stable when reference is analyzed |
change_over_time.min |
time where the signal is unstable after switching from reference to sample or back |
sample_block_time.min |
time where the signal is stable when sample is analyzed |
startup_time.min |
initial time to stabilize spray |
ref_block_name |
the name of the reference being measured |
sample_block_name |
the name of the sample being measured |
A data frame (tibble) with block annotations in the form of the additional columns described below:
data_group
is an integer that numbers each data group (whether that's startup, a sample block, a segment, etc.) in each file sequentially to uniquely identify groups of data that belong together - this columns is NOT static (i.e. functions like orbi_adjust_block()
and orbi_segment_blocks()
will lead to renumbering) and should be used purely for grouping purposes in calculations and visualization
block
is an integer counting the data blocks in each file (0 is the startup block)
sample_name
is the name of the material being measured as defined by the ref_block_name
and sample_block_name
parameters
segment
is an integer defines segments within individual blocks - this will be NA
until the optional orbi_segment_blocks()
is called
data_type
is a text value describing the type of data in each data_group
- for a list of the main categories, call orbi_get_settings("data_type")
This functions exports the final dataset
into an Excel file.
orbi_export_data_to_excel( dataset, file, dbl_digits = 7, int_format = "0", dbl_format = sprintf(sprintf("%%.%df", dbl_digits), 0) )
orbi_export_data_to_excel( dataset, file, dbl_digits = 7, int_format = "0", dbl_format = sprintf(sprintf("%%.%df", dbl_digits), 0) )
dataset |
data frame |
file |
file path to export the file |
dbl_digits |
how many digits to show for dbls (all are exported) |
int_format |
the excel formatting style for integers |
dbl_format |
the excel formatting style for doubles (created automatically from the dbl_digits parameter) |
returns dataset invisibly for use in pipes
This function filters out data that have been previously flagged using functions orbi_flag_satellite_peaks()
, orbi_flag_weak_isotopocules()
, and/or orbi_flag_outliers()
. Note that this function is no longer necessary to call explicitly as orbi_analyze_shot_noise()
and orbi_summarize_results()
automatically exclude flagged data.
orbi_filter_flagged_data(dataset)
orbi_filter_flagged_data(dataset)
dataset |
a tibble with previously flagged data from |
a dataset with the flagged data filtered out
A basic filter function orbi_filter_isox()
for file names, isotopocules, compounds and time ranges. Default value for all parameters is NULL, i.e. no filter is applied.
orbi_filter_isox( dataset, filenames = NULL, compounds = NULL, isotopocules = NULL, time_min = NULL, time_max = NULL )
orbi_filter_isox( dataset, filenames = NULL, compounds = NULL, isotopocules = NULL, time_min = NULL, time_max = NULL )
dataset |
The IsoX data to be filtered |
filenames |
Vector of file names to keep, keeps all if set to |
compounds |
Vector of compounds to keep, keeps all if set to |
isotopocules |
Vector of isotopocules to keep, keeps all if set to |
time_min |
Minimum retention time in minutes ( |
time_max |
Maximum retention time in minutes ( |
Filtered tibble
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_filter_isox( filenames = c("s3744"), compounds = "HSO4-", isotopocules = c("M0", "34S", "18O") )
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_filter_isox( filenames = c("s3744"), compounds = "HSO4-", isotopocules = c("M0", "34S", "18O") )
orbi_flag_satellite_peaks()
Function replaced by orbi_flag_satellite_peaks()
orbi_filter_satellite_peaks(...)
orbi_filter_satellite_peaks(...)
... |
parameters passed on to the new function |
orbi_flag_outliers()
Function replaced by orbi_flag_outliers()
orbi_filter_scan_intensity(..., outlier_percent)
orbi_filter_scan_intensity(..., outlier_percent)
... |
parameters passed on to the new function |
outlier_percent |
outlier_percent needs to be between 0 and 10, flags extreme scans based on TIC x injection time (i.e., ion intensity) |
orbi_flag_weak_isotopocules()
Function replaced by orbi_flag_weak_isotopocules()
orbi_filter_weak_isotopocules(...)
orbi_filter_weak_isotopocules(...)
... |
parameters passed on to the new function orbi_flag_weak_isotopocules(). |
Finds all .isox files in a folder.
orbi_find_isox(folder, recursive = TRUE)
orbi_find_isox(folder, recursive = TRUE)
folder |
path to a folder with isox files |
recursive |
whether to find files recursively |
# all .isox files provided with the isoorbi package orbi_find_isox(system.file("extdata", package = "isoorbi"))
# all .isox files provided with the isoorbi package orbi_find_isox(system.file("extdata", package = "isoorbi"))
The function orbi_flag_outliers()
flags outliers using one of the different methods provided by the parameters (to use multiple, please call this function several times sequentially). Note that this function evaluates outliers within each "filename", "block", "segment" and "injection" (if these columns exist), in addition to any groupings already defined before calling this function using dplyr's group_by()
. It restores the original groupings in the returned data frame.
orbi_flag_outliers(dataset, agc_fold_cutoff = NA_real_, agc_window = c())
orbi_flag_outliers(dataset, agc_fold_cutoff = NA_real_, agc_window = c())
dataset |
Simplified IsoX dataset to have outliers flagged |
agc_fold_cutoff |
flags scans with a fold cutoff based on the average number of ions in the Orbitrap analyzer. For example, |
agc_window |
flags scans with a critically low or high number of ions in the Orbitrap analyzer. Provide a vector with 2 numbers |
Function is intended to flag scans that are outliers.
The input dataset
is expected to have at least these 8 columns: filename
, scan.no
, time.min
, compound
, isotopocule
, ions.incremental
, tic
, it.ms
.
A data frame with new columns is_outlier
and outlier_type
(if they don't already exist) that flags outliers identified by the method and provides the type of outlier (e.g. "2 fold agc cutoff"), respectively.
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_flag_outliers(agc_window = c(1,99))
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_flag_outliers(agc_window = c(1,99))
Flag minor signals (e.g., satellite peaks) that were reported by IsoX (filter them out with orbi_filter_flagged_data()
).
orbi_flag_satellite_peaks(dataset)
orbi_flag_satellite_peaks(dataset)
dataset |
A data frame or tibble produced from IsoX data by |
The orbi_filter_satellite_peaks()
function removes minor signals for an isotopocule that have been reported by IsoX.
These are often small satellite peaks
generated by the Fourier transform.
If there are signal of high intensity or very many signals, this can indicate that the m/z and tolerance setting used for processing .raw files with IsoX were incorrect.
A data frame with new column is_satellite_peak
that flags satellite peaks.
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_flag_satellite_peaks()
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_flag_satellite_peaks()
The function orbi_filter_weak_isotopocules()
flags isotopocules that are not detected in a minimum of min_percent
of scans. This function evaluates weak isotopocules within each "filename", "block", "segment" and "injection" (if these columns exist), in addition to any groupings already defined before calling this function using dplyr's group_by()
. It restores the original groupings in the returned data frame.
orbi_flag_weak_isotopocules(dataset, min_percent)
orbi_flag_weak_isotopocules(dataset, min_percent)
dataset |
A simplified IsoX data frame to be processed |
min_percent |
A number between 0 and 90. Isotopocule must be observed in at least this percentage of scans (please note: the percentage is defined relative to the most commonly observed isotopocule of each compound) |
The input dataset
is expected to have at least these 8 columns: filename
, scan.no
, time.min
, compound
, isotopocule
, ions.incremental
, tic
, it.ms
.
A data frame with new column is_weak_isotopocule
that flags weak isotopocules.
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_flag_weak_isotopocules(min_percent = 2)
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_flag_weak_isotopocules(min_percent = 2)
This function provides an overview table blocks_info
which shows information on blocks in the dataset (block number, sample name, data type, scan number and start time where a block starts, and scan number and end time where a block ends).
orbi_get_blocks_info( dataset, .by = c("filename", "injection", "data_group", "block", "sample_name", "data_type", "segment") )
orbi_get_blocks_info( dataset, .by = c("filename", "injection", "data_group", "block", "sample_name", "data_type", "segment") )
dataset |
tibble produced by |
.by |
grouping columns for block info (akin to dplyr's |
a block summary or if no blocks defined yet, an empty tibble (with warning)
Calculate which stretches of the data have data for which isotopocules. This function is usually used indicrectly by orbi_plot_isotopocule_coverage()
but can be called directly to investigate isotopocule coverage.
orbi_get_isotopocule_coverage(dataset)
orbi_get_isotopocule_coverage(dataset)
dataset |
A data frame or tibble produced from IsoX data |
summary data frame
Get all isoorbi package settings
orbi_get_settings(pattern = NULL)
orbi_get_settings(pattern = NULL)
pattern |
an optional parameter with a regular expression pattern by which to sub-select the returned settings |
list of all package settings and their values
orbi_get_settings()
orbi_get_settings()
Weak isotopocules (if previously defined by orbi_flag_weak_isotopocules()
) are highlighted in the weak_isotopocules_color
.
orbi_plot_isotopocule_coverage( dataset, isotopocules = c(), x = c("scan.no", "time.min"), x_breaks = scales::breaks_pretty(5), add_data_blocks = TRUE )
orbi_plot_isotopocule_coverage( dataset, isotopocules = c(), x = c("scan.no", "time.min"), x_breaks = scales::breaks_pretty(5), add_data_blocks = TRUE )
dataset |
isox data |
isotopocules |
which isotopocules to visualize, if none provided will visualize all (this may take a long time or even crash your R session if there are too many isotopocules in the data set) |
x |
x-axis column for the plot, either "time.min" or "scan.no" |
x_breaks |
what breaks to use for the x axis, change to make more specifid tickmarks |
add_data_blocks |
add highlight for data blocks if there are any block definitions in the dataset (uses |
a ggplot object
Call this function to visualize orbitrap data vs. time or scan number. The most common uses are orbi_plot_raw_data(y = intensity)
, orbi_plot_raw_data(y = ratio)
, and orbi_plot_raw_data(y = tic * it.ms)
. By default includes all isotopcules that have not been previously identified by orbi_flag_weak_isotopcules()
(if already called on dataset). To narrow down the isotopocules to show, use the isotopocule
parameter.
orbi_plot_raw_data( dataset, isotopocules = c(), x = c("time.min", "scan.no"), x_breaks = scales::breaks_pretty(5), y, y_scale = c("raw", "linear", "pseudo-log", "log"), y_scale_sci_labels = TRUE, color = .data$isotopocule, colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), color_scale = scale_color_manual(values = colors), add_data_blocks = TRUE, add_all_blocks = FALSE, show_outliers = TRUE )
orbi_plot_raw_data( dataset, isotopocules = c(), x = c("time.min", "scan.no"), x_breaks = scales::breaks_pretty(5), y, y_scale = c("raw", "linear", "pseudo-log", "log"), y_scale_sci_labels = TRUE, color = .data$isotopocule, colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), color_scale = scale_color_manual(values = colors), add_data_blocks = TRUE, add_all_blocks = FALSE, show_outliers = TRUE )
dataset |
isox dataset |
isotopocules |
which isotopocules to visualize, if none provided will visualize all (this may take a long time or even crash your R session if there are too many isotopocules in the data set) |
x |
x-axis column for the plot, either "time.min" or "scan.no" |
x_breaks |
what breaks to use for the x axis, change to make more specifid tickmarks |
y |
expression for what to plot on the y-axis, e.g. |
y_scale |
what type of y scale to use: "log" scale, "pseudo-log" scale (smoothly transitions to linear scale around 0), "linear" scale, or "raw" (if you want to add a y scale to the plot manually instead) |
y_scale_sci_labels |
whether to render numbers with scientific exponential notation |
color |
expression for what to use for the color aesthetic, default is isotopocule |
colors |
which colors to use, by default a color-blind friendly color palettes (RColorBrewer, dark2) |
color_scale |
use this parameter to replace the entire color scale rather than just the |
add_data_blocks |
add highlight for data blocks if there are any block definitions in the dataset (uses |
add_all_blocks |
add highlight for all blocks, not just data blocks (equivalent to the |
show_outliers |
whether to highlight data previously flagged as outliers by |
a ggplot object
Call this function any time after flagging the satellite peaks to see where they are. Use the isotopocules
argument to focus on the specific isotopocules of interest.
orbi_plot_satellite_peaks( dataset, isotopocules = c(), x = c("scan.no", "time.min"), x_breaks = scales::breaks_pretty(5), y_scale = c("log", "pseudo-log", "linear", "raw"), y_scale_sci_labels = TRUE, colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), color_scale = scale_color_manual(values = colors) )
orbi_plot_satellite_peaks( dataset, isotopocules = c(), x = c("scan.no", "time.min"), x_breaks = scales::breaks_pretty(5), y_scale = c("log", "pseudo-log", "linear", "raw"), y_scale_sci_labels = TRUE, colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), color_scale = scale_color_manual(values = colors) )
dataset |
isox dataset with satellite peaks identified ( |
isotopocules |
which isotopocules to visualize, if none provided will visualize all (this may take a long time or even crash your R session if there are too many isotopocules in the data set) |
x |
x-axis column for the plot, either "time.min" or "scan.no" |
x_breaks |
what breaks to use for the x axis, change to make more specifid tickmarks |
y_scale |
what type of y scale to use: "log" scale, "pseudo-log" scale (smoothly transitions to linear scale around 0), "linear" scale, or "raw" (if you want to add a y scale to the plot manually instead) |
y_scale_sci_labels |
whether to render numbers with scientific exponential notation |
colors |
which colors to use, by default a color-blind friendly color palettes (RColorBrewer, dark2) |
color_scale |
use this parameter to replace the entire color scale rather than just the |
a ggplot object
This function creates a shot noise plot using a shotnoise
data frame created by the orbi_analyze_shot_noise()
function.
orbi_plot_shot_noise( shotnoise, x = c("time.min", "n_effective_ions"), permil_target = NA_real_, color = "ratio_label", colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666") )
orbi_plot_shot_noise( shotnoise, x = c("time.min", "n_effective_ions"), permil_target = NA_real_, color = "ratio_label", colors = c("#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666") )
shotnoise |
a |
x |
x-axis for the shot noise plot, either "time.min" or "n_effective_ions" |
permil_target |
highlight the target permil in the shotnoise plot |
color |
which column to use for the color aesthetic (must be a factor) |
colors |
which colors to use, by default a color-blind friendly color palettes (RColorBrewer, dark2) |
plot shot noise
a ggplot object
Read an IsoX output file (.isox
) into a tibble data frame.
orbi_read_isox(file)
orbi_read_isox(file)
file |
Path to the |
Additional information on the columns:
filename
: name of the original Thermo .raw
file processed by IsoX
scan.no
: scan number
time.min
: acquisition or retention time in minutes
compound
: name of the compound (e.g., NO3-)
isotopocule
: name of the isotopocule (e.g., 15N); called isotopolog
in .isox
ions.incremental
: estimated number of ions, in increments since it is a calculated number
tic
: total ion current (TIC) of the scan
it.ms
: scan injection time (IT) in millisecond (ms)
A tibble containing at minimum the columns filename
, scan.no
, time.min
, compound
, isotopocule
, ions.incremental
, tic
, it.ms
fpath <- system.file("extdata", "testfile_dual_inlet.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath)
fpath <- system.file("extdata", "testfile_dual_inlet.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath)
This step is optional and is intended to make it easy to explore the data within a sample or ref data block. Note that any raw data not identified with data_type
set to "data" (orbi_get_settings("data_type")
) will stay unsegmented. This includes raw data flagged as "startup", "changeover", and "unused".
orbi_segment_blocks( dataset, into_segments = NULL, by_scans = NULL, by_time_interval = NULL )
orbi_segment_blocks( dataset, into_segments = NULL, by_scans = NULL, by_time_interval = NULL )
dataset |
tibble produced by |
into_segments |
segment each data block into this many segments. The result will have exactly this number of segments for each data block except for if there are more segments requested than observations in a group (in which case each observation will be one segment) |
by_scans |
segment each data block into segments spanning this number of scans. The result will be approximately the requested number of scans per segment, depending on what is the most sensible distribution of the data. For example, in a hypothetical data block with 31 scans, if by_scans = 10, this function will create 3 segments with 11, 10 and 10 scans each (most evenly distributed), instead of 4 segments with 10, 10, 10, 1 (less evenly distributed). |
by_time_interval |
segment each data block into segments spanning this time interval. The result will have the requested time interval for all segments except usually the last one which is almost always shorter than the requested interval. |
Use this function to change the default package settings. When calling this function, only specify the settings you want to change, everything else will remain unchanged. The default value for each parameter is what the package uses by default for each setting.
orbi_set_settings( di_ref_name = "ref", di_sample_name = "sam", data_type_data = "data", data_type_startup = "startup", data_type_changeover = "changeover", data_type_unused = "unused", reset_all = FALSE )
orbi_set_settings( di_ref_name = "ref", di_sample_name = "sam", data_type_data = "data", data_type_startup = "startup", data_type_changeover = "changeover", data_type_unused = "unused", reset_all = FALSE )
di_ref_name |
the text label for dual inlet reference blocks |
di_sample_name |
the text label for dual inlet sample blocks |
data_type_data |
the text used to flag raw data as actually being data |
data_type_startup |
the text used to flag raw data as being part of the startup |
data_type_changeover |
the text used to flag raw data as being part of a changeover |
data_type_unused |
the text used to flag raw data as being unused |
reset_all |
if set to TRUE, will reset all settings back to their defaults |
FIXME: needs documentation completion FIXME: needs tests to change settings and then get the value back
invisible list of all settings (see orbi_get_settings()
)
Keep only columns that are directly relevant for isotopocule ratio analysis. This function is optional and does not affect any downstream function calls.
orbi_simplify_isox(dataset, add = c())
orbi_simplify_isox(dataset, add = c())
dataset |
IsoX data that is to be simplified |
add |
additional columns to keep |
A tibble containing only the 9 columns: filepath
, filename
, scan.no
, time.min
, compound
, isotopocule
, ions.incremental
, tic
, it.ms
, plus any additional columns defined in the add
argument
fpath <- system.file("extdata", "testfile_flow.isox", package="isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox()
fpath <- system.file("extdata", "testfile_flow.isox", package="isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox()
Contains the logic to generate the results table. It passes the ratio_method
parameter to the orbi_calculate_summarized_ratio()
function for ratio calculations.
orbi_summarize_results( dataset, ratio_method = c("mean", "sum", "median", "geometric_mean", "slope", "weighted_sum"), .by = c("block", "sample_name", "segment", "data_group", "data_type", "injection"), include_flagged_data = FALSE, include_unused_data = FALSE )
orbi_summarize_results( dataset, ratio_method = c("mean", "sum", "median", "geometric_mean", "slope", "weighted_sum"), .by = c("block", "sample_name", "segment", "data_group", "data_type", "injection"), include_flagged_data = FALSE, include_unused_data = FALSE )
dataset |
A tibble from |
ratio_method |
Method for computing the ratio. Please note well: the formula used to calculate ion ratios matters! Do not simply use arithmetic mean. The best option may depend on the type of data you are processing (e.g., MS1 versus M+1 fragmentation).
|
.by |
additional grouping columns for the results summary (akin to dplyr's |
include_flagged_data |
whether to include flagged data in the calculations (FALSE by default) |
include_unused_data |
whether to include unused data in the calculations (FALSE by default), in addition to peaks actually flagged as setting("data_type_data") |
Returns a results summary table retaining the columns filename
, compound
, isotopocule
and basepeak
as well as the grouping columns from the .by
parameter that are part of the input dataset
. Additionally this function adds the following results columns: start_scan.no
, end_scan.no
, start_time.min
, mean_time.min
, end_time.min
, ratio
, ratio_sem
, ratio_relative_sem_permil
, shot_noise_permil
, No.of.Scans
, minutes_to_1e6_ions
ratio
: The isotope ratio between the isotopocule
and the basepeak
, calculated using the ratio_method
ratio_sem
: Standard error of the mean for the ratio
number_of_scans
: Number of scans used for the final ratio calculation
minutes_to_1e6_ions
: Time in minutes it would take to observe 1 million ions of the isotopocule
used as numerator of the ratio calculation.
shot_noise_permil
: Estimate of the shot noise (more correctly thermal noise) of the reported ratio in permil.
ratio_relative_sem_permil
: Relative standard error of the reported ratio in permil
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_define_basepeak("M0") |> orbi_summarize_results(ratio_method = "sum")
fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi") df <- orbi_read_isox(file = fpath) |> orbi_simplify_isox() |> orbi_define_basepeak("M0") |> orbi_summarize_results(ratio_method = "sum")