Skip to contents
# load isoorbi library
library(isoorbi)

A basic data processing example

Load

# path to a test file included in the isoorbi package
# this file contains data from multiple analyses for the same compound
file_path <- system.file(package = "isoorbi", "extdata", "testfile_flow.isox")

# load data
df <- 
  file_path |>  
  # reads .isox test data
  orbi_read_isox() |>
  # optionally: keeps only most important columns; equivalent to simplify check box in IsoX
  orbi_simplify_isox()
 [158ms] orbi_read_isox() loaded 6449 peaks for 1 compound (HSO4-) with 5
isotopocules (M0, 33S, 17O, 34S, and 18O) from testfile_flow.isox
 [223ms] orbi_read_isox() read .isox data from 1 file
 [5ms] orbi_simplify_isox() kept columns filepath, filename, scan.no,
time.min, compound, isotopocule, ions.incremental, tic, and it.ms
# If you wish to read a whole folder of files, you can use the orbi_find_isox() function
# df <- "path_to_your_folder" |> orbi_find_isox() |> orbi_read_isox()

Check

Now that the data is loaded, check for satellite peaks, weak isotopocules and outliers.

# check for noise and outliers
df_flagged <- df |> 
  orbi_flag_satellite_peaks() |> # removes minor signals that were reported by IsoX in the same tolerance window where the peak of interest is
  orbi_flag_weak_isotopocules(min_percent = 2) |> # removes signals of isotopocules that were not detected at least in min_percent scans
  orbi_flag_outliers(agc_fold_cutoff = 2) # removes outlying scans that have more than 2 times or less than 1/2 times the average number of ions in the Orbitrap analyzer; another method: agc_window (see function documentation for more details)
 [203ms] orbi_flag_satellite_peaks() confirmed there are no satellite peaks
 [32ms] orbi_flag_weak_isotopocules() confirmed there are no weak
isotopocules: all are detected in at least 2% of scans in each of the 15 data
groups (based on filename, compound, and isotopocule)
 [37ms] orbi_flag_outliers() confirmed that none of the 1290 scans are
outliers based on 2 fold AGC cutoff, i.e. based on scans below 1/2 and above 2
times the average number of ions tic * it.ms in the Orbitrap analyzer, in 3
data groups (based on filename)

The info messages from these functions suggest that no data was flagged.

Calculate

# define base peak and calculate the results table
df_results <- 
  df_flagged |> 
  orbi_define_basepeak(basepeak_def = "M0")|> # sets one isotopocule in the dataset as the base peak (denominator) for ratio calculation
  orbi_summarize_results(ratio_method = "sum") # calculates ratios and generates a results table
 [80ms] orbi_define_basepeak() set M0 as the ratio denominator and calculated
5159 ratios for 4 isotopocules/base peak (33S, 17O, 34S, and 18O)
 [91ms] orbi_summarize_results() summarized ratios from 5159 peaks using the
sum method and grouping the data by filename, compound, basepeak, and
isotopocule

Visualize

# use a ggplot to plot the data
library(ggplot2)
df_results |>
  ggplot() +
  aes(
    x = sprintf("%s/%s", isotopocule, basepeak),
    y = ratio, ymin = ratio - ratio_sem, ymax = ratio + ratio_sem,
    color = filename
  ) +
  geom_pointrange() +
  scale_color_brewer(palette = "Set1") +
  orbi_default_theme() +
  labs(x = NULL, y = "ratio") +
  facet_wrap(~compound)