-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
203 lines (146 loc) · 6.72 KB
/
README.Rmd
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
title: Enhance quantitative analysis of EPMA maps with qntmap
output: github_document
---
<!-- badges: start -->
[![R build status](https://github.com/atusy/qntmap/workflows/R-CMD-check/badge.svg)](https://github.com/atusy/qntmap/actions)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://qntmap.atusy.net/LICENSE-text.html)
<!-- badges: end -->
```{r setup, include=FALSE, eval = TRUE}
knitr::opts_chunk$set(echo = TRUE, eval = FALSE)
library(knitr)
library(data.table)
```
# Overview
This package generates mass concentration maps and phase distribution maps
based on X-ray mapping data and spot analysis data from EPMA.
See "[How to]" for a usage and
[Yasumoto et al. (2018)](https://doi.org/10.2138/am-2018-6323CCBY)
for implementations.
Current version supports data from JEOL-style EPMA.
# Installation
Copy & paste a following command to R.
```r
source("https://install-github.me/atusy/qntmap")
```
# How to
1. [EPMA analysis] (spot before map)
1. [Export data] from EPMA to PC
1. [Run qntmap on R] for data processing.
Details below.
## EPMA analysis
Conversion is performed by utilizing spot analysis data as internal standards.
Thus, [spot analysis][Spot analysis] must be done prior to [mapping][Mapping].
### Spot analysis
- Analytical conditions
- Same as those conventionally applied in your lab.
- Use wavelength-dispersive X-ray spectrometer
- Spots to be analyzed
- **20 spots per phase** in the area to be mapped (the more is better).
- It is better but not necessary to quantify grains larger than mapping probe diameter.
- Make sure at least **20 spots per element** are analyzing grains
larger than mapping probe diameter.
- Identify phases in comment
- Give same comments on the same phase with the similar compositions.
- e.g., quartz, plagioclase, garnet-core, garnet-rim, ...
- An alternative is to use external file later.
### Mapping
- Analytical conditions
- Acceralating voltage must be same as that in spot analysis.
- Probe diameter should be larger than that in spot analysis.
- Probe current is recommended to be 100 nA following Lanari et al. (2014).
- Dwell time is recommended to be 0.1 - 0.3 sec following Lanari et al. (2014).
### Example of analytical conditions
| | Spot | Map | Comment |
|:--------------------|------:|--------:|:--------------------------------|
|Acceralating Voltage | 15 kV | 15 kV | Must be same in spot and map |
|Probe diameter | 3 μm | 20 μm | Must be smaller in spot than map|
|Probe current | 10 nA | 100 nA | |
|Peak dwell | 10 sec| 120 msec| |
|Background dwell | 5 sec| NA | No need to analyze in map |
## Export data {#Export}
1. **ASCII convert** mapping data into matrix format,
and save the result in the directory
where raw data is stored (e.g., `.map/1`).
1. Export whole directory of analysis containing
`.map` directory and `.qnt` directory
### Required files
#### Spot analysis
The exported data are stored in a directory named by
`.qnt` in most environments.
If using JXA-8230, a directory's name is `{PROJECT}_{#}_QNT` where
`{PROJECT}` is name of a project's name defined by user or "PROJECT" if undefined,
and`{#}` is a variable integer (e.g., `PROJECT_0001_QNT`).
```{r file-qnt, eval = TRUE, echo = FALSE}
kable(fread(system.file(package = "qntmap", "extdata", "files-qnt.csv")))
```
#### Map analysis
The exported data are stored in a directory `.map/{#}` where
`{#}` is a variable integer in most environments (e.g., `.map/1`).
If using JXA-8230, a directory name is
`{PROJECT}_{#1}_MAP_{#2}_csv` where
`{PROJECT}` is name of a project's name defined by user or "PROJECT" if undefined,
and`{#1}` and `{#2}` are variable integers (e.g., `PROJECT_0001_MAP_0001_csv`).
```{r file-map, eval = TRUE, echo = FALSE}
kable(fread(system.file(package = "qntmap", "extdata", "files-map.csv")))
```
`*` indicates wild cards.
## Run qntmap on R
For data processing.
### Interactive mode
Follow instructions shown by running the following code.
```{r interactive}
library(qntmap)
qntmap()
```
As a result,
phase identification result is saved in "`clustering`" directory and
mass concentration data as csv files in "`qntmap`" directory
both under the directory contaning mapping data.
Note that interactive mode has limited functions.
Use [manual mode][Manual mode] for full functionality.
### Manual mode
A work-flow is available with an example dataset at
https://qntmap.atusy.net/articles/qntmap.html .
```{r manual, include = FALSE, eval = FALSE}
library(qntmap)
# Required parameters
wd <- '.' # path to the working directory
dir_map <- '.map/1' # relative/absolute path to the directory containing ascii converted X-ray map files (1_map.txt, 2_map.txt, and so on)"
dir_qnt <- '.qnt' # relative/absolute path to the directory containing .qnt files (pkint.qnt, net.qnt, and so on)"
# Optional parameters
## A character vector to specify phases tend to be smaller than mapping probe diameter
fine_phase <- NULL
## A csv file indicating name of the phase of n-th quantitative point analysis.
## The file path is absolute or relative to `dir_qnt`.
## If NULL, names are assumed to be specified in comments during EPMA analysis.
phase_list <- NULL
# Run analysis
# Set working directory
setwd(wd)
# Load mapping data
# Change value of DT (dead time in nanoseconds) depending on EPMA.
# 1100 ns is a value applied by JEOL JXA-8105.
xmap <- read_xmap(wd = dir_map, DT = 1100)
# Compile quantitative data
qnt <- read_qnt(wd = dir_qnt, phase_list = phase_list, renew = TRUE)
## Check 'phase_list0.csv' under 'dir_qnt' to see if name of phases are provided properly.
## If not, modify the csv file and specify the path of modified one to `phase_list` in "Optional parameters" section and rerun the above code.
# Determine initial cluster centers
centers <- find_centers(xmap = xmap, qnt = qnt, fine_phase = fine_phase)
## Check 'centers0.csv' under the `wd` and modify on demand.
## If modified, assign content of the modified csv file by running
## centers <- data.table::fread('path to the modified csv file')
# Phase identification
# Assign group_cluster = TRUE if you want to integrate same phases subgrouped by suffix after '_'
# (e.g., garnet_a and garnet_b are integrated to garnet if TRUE)
cls <- cluster_xmap(xmap = xmap, centers = centers, group_cluster = FALSE)
# Quantify X-ray maps
qmap <- quantify(
xmap = xmap, qnt = qnt, cluster = cls, fine_phase = fine_phase
)
## Resulting files are saved in `qntmap` directory` under `dir_map`.
# Summarize result
summary(qmap)
## This shows minimum, lower quantile, median, mean, upper quantile, and maximum values of variables.
```