Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
122 lines (97 sloc) 4.21 KB
---
title: "Dual Inlet Examples"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Dual Inlet Examples}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
# Introduction
Isoprocessor supports several plotting and data conversion functions specifically for dual inlet data. This vignette shows some of the functionality for dual inlet files read by the [isoreader package](http://isoprocessor.isoverse.org) (see the [corresponding vignette](http://isoreader.isoverse.org/articles/dual_inlet.html) for details on data retrieval, storage and export).
```{r, warning=FALSE, message=FALSE}
# load isoreader and isoprocessor packages
library(isoreader)
library(isoprocessor)
```
# Reading files
```{r}
# read dual inlet examples provided by the isoreader package
iso_files <-
iso_read_dual_inlet(
iso_get_reader_example("dual_inlet_example.did"),
iso_get_reader_example("dual_inlet_example2.did"),
iso_get_reader_example("dual_inlet_example.caf")
)
```
# Visualization
Plotting the raw data can be done either with the generic `iso_plot_raw_data()` function for a simple plot with default parameters, or directly using the dual inlet specific `iso_plot_dual_inlet_data()`:
```{r "all_data", fig.width = 12, fig.asp = 0.8}
iso_files %>% iso_plot_dual_inlet_data()
```
All customization options are described in the function help (`?iso_plot_dual_inlet_data`) and include, for example, plotting only a specific subset of masses:
```{r "select_masses", fig.width = 10, fig.asp = 0.3}
iso_files %>%
# plot just masses 2, 44 and 45
iso_plot_dual_inlet_data(
data = c("28", "44", "45")
)
```
# Isotope ratios
For dual inlet applications isotope ratios calculated using the recorded ion intensities are typically of primary interest. For this purpose, isoreader provides a dynamic ratio calculation function (`iso_calculate_ratios()`) that accepts any combination of masses, here demonstrated for several different ratios. In this context, another useful customization option of the plotting function is the option to adjust plot aesthetics such as color, shape, and paneling:
```{r "ratios", fig.width = 8, fig.asp = 1}
iso_files <-
iso_files %>%
# calculate 46/44, 45/44 and 32/28 (O2/N2) ratios
iso_calculate_ratios(ratios = c("46/44", "45/44", "32/28"))
iso_files %>%
iso_plot_dual_inlet_data(
# visualize ratios
data = c("45/44", "46/44", "32/28"),
# panel the ratios vs. type (standard/sample)
panel = data ~ type,
# color by the file info stored in Identifier 1
color = `Identifier 1`
)
```
# Signal conversion
Isoreader can convert between different signal units. This is particularly useful for comparing data files from different mass specs that record primary signals differentally. In dual inlet applications, this is typically less important than in continuous flow because data is usually visualized as ratios right away. However, occassionally it can be of interest to examine the primary ion currents.
```{r "signal_conversion", fig.width = 10, fig.asp = 0.3}
iso_files$dual_inlet_example.caf %>%
# convert all signals to nano ampere
iso_convert_signals(to = "pA") %>%
# plot primary ion currents
iso_plot_dual_inlet_data(
data = c("45", "47", "48"),
color = type
)
```
# Plot styling
Since all isoreader plots are standard [ggplot](http://ggplot2.tidyverse.org/) objects, they can be modified with any ggplot commands. For example to add a horizontal line (using [dplyr](http://dplyr.tidyverse.org/) for the calculations) and modify the themes:
```{r "plot styling", message=FALSE, fig.width = 8, fig.asp = 0.7}
library(ggplot2)
library(dplyr)
iso_files %>%
# replot
iso_plot_dual_inlet_data(
data = "45/44",
panel = type ~ `Identifier 1`,
color = `Identifier 1`
) +
# add horizontal line indicating the averages (using a ggplot geom)
geom_hline(
data = function(df) {
df %>%
group_by(`Identifier 1`, type, data) %>%
summarize(value = mean(value))
},
mapping = aes(yintercept = value)) +
# modify plot styling (ggplot functionality)
theme(text = element_text(size = 20))
```
You can’t perform that action at this time.