Sunday, June 17, 2018

Using R: consistent treatment of data in the lab


Typically geochemical data is treated rather poorly; it often starts with a clean Excel spreadsheet and ends with a mess of calculations and ugly plots. In this post I share what I learned about manipulating data in R using tidyverse packages. Particularly, I focus on keeping the data clean, columns in good shape and consistent treatement of data.

For example, in the last 4 years, I have been working in a stable isotope lab and thus, I've produced a lot of measurements. Having lot of measurements compiled in data sets is great, however now I have a hard time treating the data consistently.

The main problem is in small day-to-day deviations in the data monitored by analysis of standards. Because of that each sessions includes a set of standards along with unknowns. The difference between measured and nominal value of standards is used adjust the rest of the data. Having to do this, it is almost impossible to use Excel when dealing with large amounts of data.

TASK: adjust the values of unknowns based on the standards measured during different analytical sessions.

DETAILS: named UOG is measured for d18O within each analytical session, it should have value of 6.52 per mil but deviations within 0.5 - 1 per mil occur. The difference (excess or deficiency) between the measured value of UOG and 6.52 should be applied to the data set on that particular day.

LOGICAL APPROACH: compile all the data in a single file. Each column is a separate variable. At least three of them: Date of analytical session, Sample name, Measured d18O value. I will instruct the machine how to average out standards within each session and apply the difference between nominal and average value to the rest of the data.

COMPUTING APPROACH is provided below. The instructions are created using RMarkdown document. With some basic familiarity with R this should be easy.


Wednesday, April 25, 2018

Oxygen isotopes and delta notation: Cheat sheet v1

I prepared a cheat sheet for oxygen isotopes to keep all relevant info in one place. It is designed for my own needs but could be useful for students and researchers. The cheat sheet provides essential information on d18O notations, values of common reservoirs, fractionation factors (1000lnα), Δ17O, etc. Feel free to use it, print it and please, provide me with constructive feedback (in the comments or at dzakharovgeo@gmail.com)

oxygen_isotopes_cheatsheet_v1.pdf
oxygen_isotopes_cheatsheet_v1.pptx


Friday, November 24, 2017

Test version for formula calculator...behold

amphibole formula unit calculator

amphibole formula unit calculator

This calculator coverts wight percent oxides to formula units for major rock-forming minerals. Determining Fe2+/Fe3+ ratio is available for amphiboles only using Droop (1972) algorithm.

Element %
Value

Wednesday, October 18, 2017

Interactive elemental maps




This post features interactive elemental maps that were created for plotting electron microprobe analysis (see previous entry). Now you can visualize the output without needing to install any software. Elemental maps show distribution of concentration for each element in spacial 2D coordinates, X and Y. In this particular example a komatiitic basalt with some alteration is used. You can navigate the analysis by choosing different element and hovering the mouse over the image to see the concentration of the chosen element (Z axis). 

The colors reflect the concentration corresponding to the wt. % value on the color bar. When Al2O3 is selected (default), elongated grains of clinopyroxene are shown with blue color (relatively ow Al2O3). This can be compared to concentration of other elements: high Ca, high Mg. This is a pyroxene pigeonite-augite. If the sample studied in SiO2 mode, one can clearly see quartz - red patches denote high concentrations of silica.

THE LINK TO INTERACTIVE MAP

The code is written in R with plotly package for plotting ans ShinyApp package  to create an interactive output. Let me know if you would like to try this code for your own elemental maps. 

Saturday, October 14, 2017

Automated petrography: electron microprobe mapping

 altered basalt from modern seafloor
(ownership: http://www-odp.tamu.edu/)

In the world of geochemistry every sample requires a detailed description. To make sense out of isotopic/chemical measurements it is important to know what each sample is composed of and how much of each component is present. One of my project deals with ancient altered basalts - something not a lot of people like to look under microscope at because of absence of primary minerals and general "mess" composed of secondary minerals. Basalts are commonly fine-grained in the first place and alteration can make them particularly microscopic; they are altered to fine-grained aggregate of  secondary minerals - chlorites, serpentines, epidotes, amphiboles and other minerals of hydrothermal origin. Even under petrographic microscope these minerals are sometimes indistinguishable from each other. In my study, I used microprobe analysis to go around this problem. With help of John Donovan from the electron microprobe analysis lab at the University of Oregon, we programmed the instrument to create maps of elemental distribution. Resulted images are posted below. I selected most contrasting elements for each sample and plotted them using R package ggplot2. Each pixel in these images represent an electron microprobe analysis.
 Panel image: A - altered basalt with komatiitic texture. Image size is 500 um along the side; B - a quartz-calcite vein with epidote, amphibole, diopside and garnet; C - fragment of altered pillow that is altered to muscovite, chlorite, amphibole and albite (200 um along the side). Abbreviations: albite (ab), amph (amphibole), cc (calcite), chl (chlorite), di (diopside), gt (garnet), ep (epidote).

Now having these images and tens of thousands of analysis I can derive composition of each mineral with very high accuracy. Using some programming algorithms I extracted a composition of a given mineral from each image and processed them to compute formula units of each mineral. Below is results plotted on classification diagrams for epidote (A), pyroxenes (B), Ca-amphiboles (C) and chlorites (D). White transparent fields are plotted using literature data on modern altered basalts (drill hole ODP 504B, eastern Pacific Ocean).



 Panel image: A - analyzed epidotes plotted on classification diagrams using end-members - epidote (Ep), clinozoisite (Clz) and two times piemontite (2Pmt); B - analyzed clinopyroxenes plotted on classification diagram for calcic pyroxenes; C - analyzed calcic amphiboles plotted on classification diagram (after Leake, 1978); D - analyzed chlorites on classification diagram (after Hay, 1954). White transparent fields are using published results for secondary minerals from the drill hole ODP 504B. Analysis of my ancient basalts show that they are composed of minerals pretty similar to those formed on modern day seafloor!

Monday, April 3, 2017

The most convincing evidence for CO2 increase

Today global warming and climate change are widely discussed. Many people refer to "scientific evidence" that proves that climate change is caused by humans, by burning fossil fuel in particular. However, I rarely hear on public media discussion of the actual data and interpretations that serve as the scientific evidence for human-induced climate change. May be there would be more productive conversation between different members of our society on climate change if the public media discussions included some background on the scientific evidence. 

Human-induced climate change has expressed itself in elevated concentrations of CO2 in the atmosphere. Elevated CO2 is a consequence of releasing carbon in the atmosphere through burning fossil fuel like coal and petrol. Among multiple evidences for such change, glacial ice cores represent the most convincing indication of human-induced elevated CO2 levels. As glacial ice forms every year it trap atmospheric air in the form of bubbles. Extracted from drill holes, glacial ice cores can be accurately dated to the recent time line (back to several thousand years). Extracted air bubbles are analyzed for concentration of gases and isotopic composition of the gases. This graph below copied from "Stable Isotope Geochemistry" by Hoefs represents the most convincing evidence for human-induced climate change.


 

Clear increase in CO2 concentration (plot a) starting at about 1850 marks the bloom of the industrial era. Plot B shows the carbon isotopic composition (δ13C, ‰; delta carbon thirteen) of CO2 from the atmosphere. Starting from industrial era, it becomes more negative, meaning CO2 molecules in the atmosphere are increasingly depleted in the heavier isotope of carbon - 13C - with respect to the lighter carbon, 12C. Organic matter, like coal, is extremely "light" carbon, means it is depleted in heavy carbon 13C. Burning such "light" source of carbon makes CO2 in the atmosphere "light" as well. Just for clarification, I include here a diagram from the same book on isotopic composition of all carbon sources known to Earth. It show that organic matter (such as fossil fuel) is the source of isotopically "light" carbon.

 


EDIT:
It was pointed out that the isotopic composition of CO2 from volcanoes should be shown too since volcanic emanations contribute to the level of atmospheric CO2. Valid point. The δ13C from volcanoes is almost identical to the δ13C of the air. See attached diagram. 
The image is taken from a Pennsylvania State University website