powdR: Full Pattern Summation of X-ray Powder Diffraction Data

Benjamin Butler


1 Overview

powdR is an R implementation of the full pattern summation approach to quantitative mineralogy from X-ray powder diffraction (XRPD) data. Whilst this is available in Excel spreadsheets such as FULLPAT (Chipera and Bish 2002) and RockJock (Eberl 2003), implementation in R allows for faster computation than is currently available, and provides a user-friendly Shiny application to help with the often iterative process of mineral quantification. Furthermore, the afps() function in powdR is designed to automate the full pattern summation procedure, which is particularly advantageous in high-throughput XRPD datasets.

2 Full pattern summation

A powerful property of XRPD data is that it can provide quantitative estimates of phase concentrations in mineral mixtures. Though several methods are available for such quantitative analysis, full pattern summation (also referred to as “full pattern fitting of prior measured standards”) is particularly suitable for mixtures containing crystalline mineral phases in combination with disordered and/or X-ray amorphous phases. Soil is a prime example of such mixtures, where crystalline minerals such as quartz and feldspars can be present in combination with clay minerals (i.e. disordered phases), and organic matter (i.e. amorphous phases).

The full pattern summation implemented in powdR is based on the principle that an observed pattern is comprised of the sum of signals from the individual components within it. A key component of this approach is a library containing measured or calculated patterns of the pure phases that may be encountered within the samples. These “reference”" patterns would ideally be measured on the same instrument as the sample. To quantify a given sample, suitable phases from the library are selected that together account for all peaks within the data, and their relative contributions to the observed signal optimised until an appropriate fit is achieved (Chipera and Bish 2002). This fit is usually refined using least squares optimisation of an objective parameter. The scaled intensities of the optimised patterns are then converted to weight % using reference intensity ratios, which are a measure of diffracting power relative to a standard mineral (usually corundum).

#Using powdR

2.1 The powdRlib object

A key component of the functions within powdR is the library of reference patterns. These are stored within a powdRlib object created using the powdRlib() constructor function. powdRlib() builds a powdRlib object from two components. The first component, specified via the xrd_table argument of powdRlib(), is a data frame of the count intensities of the reference patterns, with their 2\(\theta\) axis as the first column. The column for a given reference pattern must be named using a unique identifier (a phase ID). An example of such a format is provided in the minerals_xrd data:

The second component required to build a powdRlib object (specified via the phases_table argument of powdRlib()) is a data frame containing 3 columns. The first is a string of unique ID’s representing each reference pattern in the data provided to the xrd_table argument. The second column is the name of the phase group that this reference pattern belongs to (e.g. quartz or glass). The third column is the reference intensity ratio (RIR) of that reference pattern (relative to a known standard, usually corundum). An example of the format required for the phases_table argument of powRlib() is provided in the minerals_phases data.

Crucially when building the powdRlib object, all phase ID’s in the first column of the phases_table must match the column names of the xrd_table (except the name of the first column which is the 2\(\theta\) scale), for example.

Once created, powdRlib objects can easily be visualised using plot(), which when used for powdRlib objects accepts the arguments wavelength and refs that are used to specify the X-ray wavelength and the reference patterns to plot, respectively. In all cases where plot() is used hereafter, the addition of interactive = TRUE to the function call will produce an interactive html graph.

2.2 RockJock

There are two powdRlib objects provided as part of the powdR package. The first is minerals (accessed via data(minerals)), which is a simple and low resolution library designed to facilitate fast computation of basic examples. The second is rockjock (accessed via data(rockjock)), which is a comprehensive library of 168 reference patterns covering most phases that might be encountered in geological and soil samples. The rockjock library in powdR uses data from the original RockJock program (Eberl 2003) thanks to the permission of Dennis Eberl. In rockjock, each reference pattern from the original RockJock program has been scaled to a maximum intensity of 10000 counts, and the RIR’s normalised relative to Corundum. All rockjock data were analysed using Cu K\(\alpha\) radiation.

##RockJock synthetic mixtures To accompany the rockjock reference library, a list of eight synthetic mixtures from the original RockJock program (Eberl 2003) are also included in powdR in the rockjock_mixtures data (accessed via data(rockjock_mixtures). Their known weights (see ?rockjock_mixtures) can be compared to full pattern summation outputs (i.e. from fps() and afps(), detailed below) to assess accuracy.

##Subsetting a powdRlib object Occasionally it may be useful to subset a reference library to a smaller selection. This can be achieved using subset(), which for powdRlib objects accepts three arguments; x, refs and mode. The x argument specifies the powdRlib object to be subset, refs specifies the ID’s of phases to select, and mode specifies whether these phases are kept (mode = "keep") or removed (mode = "remove").

2.3 Full pattern summation:

Full pattern summation in powdR is provided via fps(), and an automated version provided in afps(). Here the rockjock and rockjock_mixtures data will be used to demonstrate the use of these functions.

2.3.1 Full pattern summation with internal standard

In some cases samples are prepared for XRPD with an internal standard of known concentration. If this is the case, then the std_conc argument of fps() and afps() can be used to define the concentration of the internal standard (in weight %), which is used in combination with the reference intensity ratios to compute phase concentrations. For example, all samples in the rockjock_mixtures data were prepared with 20 % corundum as the internal standard, thus this can be specified using using std = "CORUNDUM" and std_conc = 20 in the call to fps() or afps().

Notice that when the std_conc is defined, the computed phase concentrations exclude the contribution of the internal standard…

…and that the phase concentrations do not sum to 100 %.

Unlike other software where only certain phases can be used as an internal standard, any phase can be defined in powdR. For example, the rockjock_mixtures$Mix5 sample contains 20 % quartz (see ?rockjock_mixtures), thus adding "QUARTZ" as the std argument results in this reference pattern becoming the internal standard.

2.3.2 Full pattern summation without internal standard

In cases where an internal standard is not added to a sample, phase quantification can be achieved by assuming that all detectable phases can be identified and that they sum to 100 weight %. By setting the std_conc argument of fps() or afps() to NA, or leaving it out of the function call, it will be assumed that the sample has been prepared without an internal standard and the phase concentrations computed accordingly.

In this case the phase specified in the std argument is only used for sample alignment, and is included in the computed phase concentrations.

Furthermore, the phase concentrations sum to 100 %.

2.3.3 Full pattern summation with data harmonisation

It is usually recommended that the reference library used for full pattern summation is measured on the same instrument as the sample using an identical 2\(\theta\) range and resolution. In some cases this is not feasible, and the reference library patterns may be from a different instrument to the sample. To allow for seamless use of samples and libraries from different instruments (measured on the same wavelength), fps() and afps() contain a logical harmonise argument (default = TRUE). When the sample and library contain non-identical 2\(\theta\) axes, harmonise = TRUE will convert the data onto the same scale by determining the overlapping 2\(\theta\) range and interpolating to the coarsest resolution available.

2.4 Automated full pattern summation

The selection of suitable reference patterns for full pattern summation can often be challenging and time consuming. An attempt to automate this process is provided in afps(), which can select appropriate reference patterns from a reference library and subsequently exclude reference patterns based on limit of detection estimates. Such an approach is considered particularly advantageous when quantifying high-throughput XRPD datasets that display considerable mineralogical variation.

Here the rockjock library, containing 168 reference patterns, will be used to quantify one of the samples in the rockjock_mixtures data.

2.5 Plotting

Plotting results from fps() or afps() (powdRfps and powdRafps objects, respectively) is achieved using plot(). Static ggplot() plots can be created using:

Alternatively, interactive ggplotly() plots can be created by adding interactive = TRUE to the function call, e.g. plot(fit_5, wavelength = "Cu", interactive = TRUE).

##Quantifying multiple samples The easiest way to quantify multiple samples is with lapply()

##Summarising mineralogy When multiple samples are quantified, it is often useful to report the phase concentrations of all of the samples in a single table. For a given list of powdRfps and/or powdRafps objects, the summarise_mineralogy() function yields such summary tables, for example:

where type = "grouped" denotes that phases with the same phase_name will be summed together, and order = TRUE specifies that the columns will be ordered from most common to least common (assessed by the sum of each phase across the samples).

2.6 The powdR Shiny app

To run powdR via the Shiny app, use run_powdR(). This loads the application in your default web browser. The application has eight tabs:

  1. Reference Library Builder: Allows you to create and export a powdRlib reference library from two .csv files: one for the XRPD measurements, and the other for the ID, name and reference intensity ratio of each pattern.
  2. Reference Library Viewer: Facilitates quick inspection of the phases within a powdRlib reference library.
  3. Reference Library Editor: Allows the user to easily subset a powdRlib reference library .
  4. Full Pattern Summation: A user friendly interface for iterative full pattern summation of single samples.
  5. Automated Full Pattern Summation: A user friendly interface for automated full pattern summation of single samples.
  6. Results viewer: Allows for quick inspection of results derived from full pattern summation.
  7. Results editor: Allows for results from previously saved powdRfps and powdRafps objects to be edited via addition or removal of reference patterns to the fitting process.
  8. Help Provides a series of video tutorials (via YouTube) detailing the use of the powdR Shiny application.


Chipera, Steve J., and David L. Bish. 2002. “FULLPAT: A full-pattern quantitative analysis program for X-ray powder diffraction using measured and calculated patterns.” Journal of Applied Crystallography 35 (6): 744–49. https://doi.org/10.1107/S0021889802017405.

Eberl, D. D. 2003. “User’s guide to ROCKJOCK - A program for determining quantitative mineralogy from powder X-ray diffraction data.” Boulder, CA: USGS.