wd <- tempdir()
knitr::opts_chunk$set(
  root.dir = wd,
  fig.width = 5,
  fig.height = 5,
  collapse = TRUE,
  comment = "#>"
)
library(qntmap)
library(dplyr)
library(pipeR)
library(ggplot2)

Intro

This document introduces a way to quantify X-ray map even if, in accident, there are some phases without spot analysis. For accurate analysis, I highly recommend careful observation prior to EPMA analysis, so that as less phases as possible being missed.

Please read "Get started" before hand.

Preparation

This section prepares package, files, and modify sample data. An original sample dataset is same as that used in "Get started". However, the dataset will be modified to let a phase be not analyzed by EPMA spot analysis. This is why "[Specify directories containing data]" and "[Load Data]" belongs to "[Preparation]" despite they belongs to Analysis section of "Basic usage".

Load package

library(qntmap)

Move to working directory

wd <- tempdir() # Arbitrary
setwd(wd)

Copy example data

or any original data.

file.copy(
  from = system.file('extdata', 'minimal', package = 'qntmap'),
  to = wd,
  recursive = TRUE
)

TRUE indicates files are successfully copied. Check if really files are copied by dir().

dir(file.path(wd, 'minimal'), recursive = TRUE, all.files = TRUE)

Specify directories containing data

dir_map <- file.path(wd, 'minimal/.map/1')
dir_qnt <- file.path(wd, 'minimal/.qnt')
dir_map <- 'minimal/.map/1'
dir_qnt <- 'minimal/.qnt'

Load data

xmap <- read_xmap(dir_map)
qnt <- read_qnt(dir_qnt)

Check quantified data

In the original dataet, 20 spots are analyzed by EPMA on both olivine and quartz.

table(qnt$cnd$phase)

Modify data

Let's delete quartz from dataset and reload.

After read_qnt() is performed, a file phase_list0.csv is created under working directory. This file consists of 3 columns id, phase, and use.

Edit only phase and use. Do not edit id. If certain phases have large compositional variations, fill phase column with different names. (e.g., Ol_Fe and Ol_Mg for Fe-rich olivine and Mg-rich olivine). If certain analysis show bad results, fill use column with FALSE, otherwise TRUE.

To do it on R, execute codes below. Be sure to specify a path to modified csv file to phase_list parameter of read_qnt. Also, renew parameter of read_qnt must be TRUE.

phase_list <- read.csv('phase_list0.csv')
phase_list$use[phase_list$phase == 'Qtz'] <- FALSE
write.csv(phase_list, file.path(dir_qnt, 'phase_list_no_qtz.csv'))
qnt <- read_qnt(dir_qnt, phase_list = file.path(dir_qnt, 'phase_list_no_qtz.csv'))

After editing, only olivine is said to be quantified.

table(qnt$cnd$phase)
epma <- tidy_epma(qnt, xmap) %>>%
  filter(elm == elm[[1]]) %>>%
  select(x_px, y_px, phase)

plot(xmap, 'Si', interactive = FALSE, colors = "gray") +
  geom_point(
    aes(y_px, x_px, colour = phase),
    data = epma, inherit.aes = FALSE
  ) +
  guides(
    fill = guide_colourbar(barheight = grid::unit(1, "npc") - unit(10, "line"))
  )

Analysis

Cluster analysis

Initialize cluster centers

centers <- find_centers(xmap, qnt)
centers

Compare the initial centroids with X-ray map plotted with heatmap

plot(xmap, 'Si', interactive = FALSE)

In this case, an analysist will notice there is something other than olivine. Let's mouse over the interactive map and one will see one of the coordinates of quartz (e.g., x = 18, y = 28). Keep it on your note.

Add initial centers

on R

Add initial centers by using add_centers.

centers <- add_centers(centers = centers, xmap = xmap, x = 18, y = 28, p = 'Qtz')

Then, Qtz is properly added to centers.

print(centers)

on Spreadsheet program + R

Cluster and quantify

As Qtz is not quantified during spot analysis, calibration curves for Qtz is substituted by results of regression analysis without considering different phases. Try "[Quasi-calibrations]" in case phases not quantified have known and constant chemical compositions.

cluster <- cluster_xmap(xmap, centers)
qmap <- quantify(xmap, qnt, cluster)
summary(cluster)
summary(qmap)

Quasi-calibrations

In case phases without spot analysis have known chemical compositions, their calibration curves can be calculated by specifying their chemical compositions in csv format.

For example, prepare a csv file, and specify it to fix parameter of quantify().

csv <- paste(
    'phase, oxide, wt',
    'Qtz,   SiO2,      100',
    sep = "\n"
  )
cat(csv)
qmap2 <- quantify(xmap, qnt, cluster, fix = csv)
summary(qmap2)

Of course, csv parameter can be a path to a csv file, unlike the above example, which gave csv data the csv parameter.

unlink(c('centers0.csv', 'center_add.csv'))


atusy/qntmap documentation built on April 11, 2021, 4:45 p.m.