-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan.Rmd
More file actions
119 lines (91 loc) · 3.47 KB
/
scan.Rmd
File metadata and controls
119 lines (91 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
title: "Scan Examples"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Scan 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 for scan data. This vignette shows some of the functionality for scan files read by the [isoreader package](http://isoprocessor.isoverse.org) (see the [corresponding vignette](http://isoreader.isoverse.org/articles/scan.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 scan examples provided by the isoreader package
scan_files <-
iso_read_scan(
iso_get_reader_example("peak_shape_scan_example.scn"),
iso_get_reader_example("background_scan_example.scn"),
iso_get_reader_example("full_scan_example.scn"),
iso_get_reader_example("time_scan_example.scn")
)
```
# 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 scan specific `iso_plot_scan_data()`:
## Voltage Scan
```{r "all_data_HV", fig.width = 12, fig.asp = 0.8}
iso_plot_scan_data(scan_files, type = "High Voltage")
```
## Magnet Scan
```{r "all_data_magnet", fig.width = 12, fig.asp = 0.8}
iso_plot_scan_data(scan_files, type = "MagnetCurrent")
```
## Time Scan
```{r "all_data_clock", fig.width = 12, fig.asp = 0.8}
iso_plot_scan_data(scan_files, type = "Clock")
```
## Customization
All customization options are described in the function help (`?iso_plot_scan_data`) and include, for example, plotting only a specific subset of masses:
```{r "select_masses", fig.width = 10, fig.asp = 0.3}
# plot just masses 44 and 45
iso_plot_scan_data(
scan_files, type = "High Voltage",
data = c("44", "45")
)
```
# Isotope ratios
Isoprocessor 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}
scan_files <-
scan_files %>%
# calculate 46/44, 45/44
iso_calculate_ratios(ratios = c("46/44", "45/44"))
iso_plot_scan_data(
scan_files, type = "High Voltage",
# visualize masses and ratios
data = c(44:46, "45/44", "46/44"),
# focus on peak
x_interval = c(9.44, 9.49),
# panel including by category
panel = category ~ file_id
)
```
# Signal conversion
Isoprocessor can convert between different signal units to examine the primary ion currents.
```{r "signal_conversion", fig.width = 10, fig.asp = 0.3}
scan_files %>%
# convert all signals to nano ampere
iso_convert_signals(to = "pA") %>%
# plot primary ion currents
iso_plot_scan_data(data = c(44, 45))
```
# Plot styling
Since all isoprocessor plots are standard [ggplot](http://ggplot2.tidyverse.org/) objects, they can be modified with any ggplot commands.
```{r "plot styling", message=FALSE, fig.width = 8, fig.asp = 0.7}
library(ggplot2)
# replot
iso_plot_scan_data(scan_files, type = "MagnetCurrent") +
# modify plot styling (ggplot functionality)
theme(text = element_text(size = 20))
```