1 Introduction

The chemical composition is the most fundamental quantitative character of igneous rocks, being a quality inherently controlled by the magma source region, degrees of partial melting, and differentiation processes during magma ascent. Therefore, the chemical composition is critical to classify rocks and address their petrogenetic aspects. The CIPW Norm calculation was initially introduced as a method for the classification and nomenclature of igneous rocks (Cross et al. 1902). Mathematically, this procedure is a linear transformation of geochemical data (major and minor element content of rocks) into a set of normative minerals from an anhydrous melt at low-pressure conditions. The algorithm that reproduces the norm has been improved by several workers (Johannsen 1931; Kelsey 1965; Pruseth 2009a; Verma et al. 2003), and as an essential petrological tool, the norm has been therefore compiled in many computational programs (Al-Mishwat 2015; Carr and Gazel 2017; Currie 1991; Glazner 1984; González-Guzmán, 2016; Gündüz and Asan 2021; Janoušek et al. 2006; Le Maitre et al. 2002; Pruseth 2009b; Stuckless 1983; Verma et al. 1986, 2002; Verma and Rivera-Gómez 2013; Williams et al. 2020; Yegorov et al. 1998; Yu et al. 2019; Zhou and Li 2006). However, there are some issues regarding the acquisition and standardization of normative mineralogy in terms of the wide range of computational codes. For example, many of those computational codes cannot be run on mainstream platforms, becoming obsolete. Most of them are also privatives, with source codes that are inaccessible to the users. Some other programs require middle to advanced command-line knowledge to be used, thereby precluding their practical usage by a wide range of users. Also, most projects cannot be executed elsewhere as they are often designed to be run in only one operating system. In addition, some software yields systematically biased results. In this sense, many researchers have argued the need to standardize the algorithm to establish normative mineralogy in igneous rocks (Verma et al. 2003; Williams et al. 2020). Thus, the general lack of precision, portability, renewability, and standardization prevents petrologists from getting a reliable norm. Such issues are the weaknesses that must be addressed in the upcoming computational projects in any scientific community (Gentleman et al. 2004; Verma and Rivera-Gómez 2013; Yu et al. 2019).

To overcome the limitations of currently available tools, a free and open-source package called shinyNORRRM (shiny: a Web Application Framework for R; NORRRM: acronym from noRm, R language, and Reneé) was developed to foster a universal programming package within the geochemical community. The package is written in R but runs as a shiny app. R is a free software environment for statistical computing and graphics (R Core Team 2022), capable of running into any operating system such as Microsoft Windows®, GNU/Linux, BSD, and Mac OS X®. R has attracted a large user base over the past several years to such an extent that it has become a popular programming language adopted by benchmark computational projects in Earth Sciences, such as IsotoplotR (Vermeesch 2018), GCDKit (Janoušek et al. 2006), phreeqc in R (Charlton and Parkhurst 2011; de Lucia and Kühn 2021), and GWSDAT (Jones et al. 2022). In addition, shiny provides a graphical user interface (GUI), such as the interactivity of modern web apps (Chang et al. 2022), combining expressive and elegant elements of R and web functions. This paper provides an overview of shinyNORRRM, which executes a stoichiometrically efficient CIPW algorithm that generates an assemblage of normative minerals and calculates multiple petrological parameters.

2 The Importance of the CIPW Norm and Its Algorithm

The norm is not an exclusive petrogenetic tool for igneous rocks as many attempts have been made to assess the normative mineralogy of sedimentary (Cohen and Ward 1991; de Caritat et al. 1994; Kackstaetter 2014; Merodio et al. 1992; Rosen et al. 2004) and metamorphic rocks (Barth 1959; Mathieu et al. 2016; Wolfgang Wagner 2022). The CIPW Norm has several variants as well (Barth 1962; Currie 1980; Janoušek et al. 2006; Usdansky 1986). In addition, there are other types of norms for igneous rocks, for instance, the Rittman Norm which is an independent algorithm that primarily addresses the classification of volcanic rocks (Rittmann 1973). It is important to note that the Rittman Norm has a procedure that handles hydrous minerals, and its results are closer to petrographic observations, especially for basalts. Nevertheless, it involves a dynamic and recursive algorithm, and nowadays, no software runs this scheme. Thus, the CIPW Norm is still the most widely used system to get the normative mineralogy for igneous rocks.

Igneous rocks are primarily classified by point-counting on thin sections or slabs (Streckeisen 1976, 1978). However, according to the IUGS (International Union of Geological Sciences; Subcommission on the Systematics of Igneous Rocks), the chemical composition is an applicable criterion for classifying rocks when their mineral mode is impossible to determine (Le Maitre et al. 2002). Therefore, the norm enables an alternative option for the classification of rocks that are difficult to constrain microscopically due to the abundance of glassy components or fine-grained (< 0.125 mm) crystals, such as those present in microcrystalline and aphanitic textures. On the other hand, for phaneritic crystalline rocks, the norm reproduces the “standard” mineralogical assemblage (Verma et al. 2003). It is worth mentioning that the examined volume in one standard-size thin section (46 × 27 × 0.03 mm) is insignificant compared to the relatively large rock volume used in the whole-rock geochemical analysis. In fact, some researchers have raised serious issues related to the modal classification of phaneritic rocks as proposed by the IUGS (e.g., Glazner et al. 2019; Middlemost 1991). In addition, determining the correct compositional variation of mineral groups such as feldspars, olivine, and pyroxene (Barron 1980; Frost et al. 2019; Paktunc 1998) is another difficulty in petrographic analyses. Therefore, it is tempting to replace the traditional modal classification considering the above-mentioned issues and the quantitative character of the normative classification.

The CIPW Norm is estimated according to a linear flowchart (Kelsey 1965; Verma et al. 2003) using a logical sequence to calculate mineral phases one after another, assigning permanent or provisional molecular proportions of the chemical components of the sample. The first sequence of calculation starts by forming accessory minerals (e.g., apatite [Ap], zircon [Zrn], and fluorite [Fr]), sulfides (thenardite [Th] and pyrite [Pr]), carbonates (calcite [Cc] and cancrinite [Ns]), and Fe-Ti oxides (chromite [Chr] and ilmenite [Ilm]). Next, silica is consumed depending on the amount of calculated silicate minerals (e.g., orthoclase [Or], albite [Al], anorthite [An], diopside [Di], hypersthene [Hyp]). Then, any excess silica is calculated as quartz [Q]. At this stage, if the sample is silica-undersaturated, the provisional silicate minerals are sequentially replaced by silica-poor minerals until the deficit is removed (e.g., nepheline [Ne] instead of albite [Al] or perovskite [Pf] instead of sphene [Tn]). This silica redistribution is confirmed by considering the silica deficiency defined by the amount of silica required minus the amount of silica in the rock at each stage of the redistribution. Finally, minerals are converted to weight percent by multiplying the molar compositions by the corresponding molecular weights.

2.1 Fe-Oxidation Ratio Adjustment

Iron (Fe) typically occurs in two oxidation states in minerals (i.e., ferric, Fe+3, and ferrous, Fe+2). For example, in the norm, ilmenite[Ilm] is presented as [FeO·TiO2] and acmite [Ac] as [Na2O·Fe2O3·4SiO2]. Unfortunately, modern analytical methods (e.g., X-ray fluorescence, inductively coupled plasma optical emission spectroscopy) only provide total Fe content expressed as either Fe2O3t or FeOt. This issue is partly responsible for the inaccuracy and the lack of standardization in norm computations because the Fe2O3/FeO ratio impacts the calculated abundance of several normative minerals. Thus, several authors have argued the need for adjustment of the Fe2O3/FeO ratio in chemical compositions of igneous rocks before any geochemical classification or CIPW Norm computation (Coombs 1963; El-Hinnawi 2016; Middlemost 1989; Pruseth 2009a; Rickwood 1989; Verma et al. 2003). Both qualitative and quantitative adjustment methods have been proposed (Brooks 1976; El-Hinnawi 2016; Hughes and Hussey 1979; Irvine and Baragar 1971; Le Maitre 1976; Middlemost 1989; Pruseth 2009a). The two most used methods for partitioning Fe between Fe2O3 and FeO are the following: (i) Middlemost’s solution (Middlemost 1989), which assigns specific values of Fe2O3/FeO based on the geochemical classification in the TAS diagram (total alkalis [K2O + Na2O] vs. silica [SiO2]) (e.g., Fe2O3/FeO [andesite] = 0.35; Fe2O3/FeO [rhyolite] = 0.50), and (ii) Le Maitre’s equations (Le Maitre, 1976), to solve Eq. (1) to specify oxidation ratios of volcanic rocks

$$ \frac{{{\text{FeO}}}}{{{\text{FeO}} + {\text{Fe}}_{2} {\text{O}}_{3} }} = 0.93 - 0.0042{\text{SiO}}_{2} - 0.022\left( {{\text{Na}}_{2} {\text{O}} + {\text{K}}_{2} {\text{O}}} \right); $$
(1)

and Eq. (2) to express the oxidation ratios of plutonic rocks

$$ \frac{{{\text{FeO}}}}{{{\text{FeO}} + {\text{Fe}}_{2} {\text{O}}_{3} }} = 0.88 - 0.0016{\text{SiO}}_{2} - 0.027\left( {{\text{Na}}_{2} {\text{O}} + {\text{K}}_{2} {\text{O}}} \right).$$
(2)

3 Software Installation and Architecture

shinyNORRRM is an extension of R and therefore launched as free software (GNU General Public License version 3.0). Users must install R language, as the package operates across this platform. Following the R standards, users can install our package by interacting with a command line in the R environment or by an R GUI (e.g., Posit [RStudio]; Fig. 1). The function “install.packages ()” can be used to install the current version from CRAN. The syntax in the terminal is as follows: install.packages (“shinyNORRRM”). In addition, our algorithm employs eight R libraries: “shiny”, “shinythemes”, “shinyWidgets”, “pracma”, “Ternary”, “grDevices”, “graphics”, and “utils”. All of them are automatically installed alongside our package.

Fig. 1
figure 1

Flowchart illustrating the installation of shinyNORRRM by interacting with a command line in the R environment or graphically through the GUI of RStudio

The functions of shinyNORRRM are written in native R using object-oriented programming. Figure 2 shows the architecture and the interface of shinyNORRRM. The native R code is coupled to the shiny libraries by generating a low-level interface, requiring server (server.r) and user interface (ui.r) codes. These components form the basic architecture behind our app. While the ui.r object controls the layout and appearance of the application, the server.r file contains the logic needed to run the functions. The main native functions (adjRock, Indices, and ultimateCIPW) require databases which include constant values such as the standard atomic, oxide, and mineral weights (Prohaska et al. 2022). The GUI consists basically of eight tabs: (i) one tab to feed the app through a delimited text format file (*.csv format); (ii–iv) three to show the numerical results of the main functions: (a) The adjusted major elements data (wt.% volatile-free), (b) The normative mineralogy (wt.%), and (c) several basic petrological parameters; and (v–viii) four tabs to show the graphical output, which corresponds to the well-known TAS scheme and some ternary classification diagrams of granitic, mafic, and ultramafic rocks, following IUGS recommendations (Le Maitre et al. 2002). Both graphical and numerical outputs are displayed on the screen and can be downloaded by specific buttons in the GUI. The output data can be downloaded in generic *.csv format, while the graphical outputs can be saved in either *.png or *.pdf formats.

Fig. 2
figure 2

Architecture of the developed CRAN, an R-based software to calculate the CIPW Norm, where: a databases containing the molecular or atomic weights reported for the IUPAC (Prohaska et al. 2022); b main functions written on native R (R Core Team 2022); c shiny app (Chang et al. 2022) as server.r and ui.r codes; d input data as *.csv format and; e a graphical user interface (GUI)

4 Discussion

4.1 shinyNORRRM Capabilities

Nowadays, our previous software, namely NORRRM, is practically obsolete and needs to be updated. shinyNORRRM includes parts of the traditional routines from NORRRM with recently developed routines and flexible self-defined functions. In the GUI, the geochemical data are extracted from an input *.csv file. shinyNORRRM emulates the algorithm presented by Verma et al. (2003) and only considers anhydrous phases. The calculation uses major (as wt.%: SiO2, Al2O3, CaO, MgO, FeO, Fe2O3, MnO, Na2O, K2O, TiO2, P2O5, LOI), minor (as wt.%: CO2, SO3, S, Cl, and F) and some trace elements (as ppm: Zr, Ba, Cr, Co, Cs, Li, Ni, Rb, Sr, V). The software allows users to report the Fe2O3 and FeO concentrations separately or as a total Fe in the same spreadsheet cell. The users also have the option to choose between Middlemost (1989) and Le Maitre (1976) to adjust the Fe-oxidation ratio or to run the norm if the input data include both Fe species. The package recalculates the major oxides to 100 wt.% on a volatile-free basis (± 0.003). In the algorithm, the concentrations of the input data are converted to moles (molecular and atomic) by dividing the content by the respective molecular or atomic weights reported for the IUPAC (Prohaska et al. 2022). The automatic use of variable molecular weights can add trace elements to major oxides in the input as follows: Ni and Co to FeO, Ba and Sr to CaO, Rb and Cs to K2O, Li to Na2O, and V to Cr2O3. The computation of cancrinite [Nc] and calcite [Cc] are allowed if the concentration of CO2 is > 0% and if the user indicates it. Apatite [Ap] can be calculated as 3CaO·P2O5·1/3CaO and 3CaO·P2O5·1/3CaF2. The ferromagnesian minerals are assumed to be free of Al2O3. Alumina content is used to determine feldspars [Or, Ab, and An] or feldspathoids [Ne and Lc] and corundum [C]. shinyNORRRM distinguishes between the end members of solid solution series such as enstatite (MgSiO3; Mg-endmember of pyroxene) and ferrosilite (FeSiO3; Fe-endmember of pyroxene) as well as forsterite (2MgO·SiO2; Mg-endmember of olivine) and fayalite (2FeO·SiO2; Fe-endmember of olivine). Several mineral pairs are incompatible in the algorithm (e.g., [Q] and [Ol] or [Hyp] and [Ne]); therefore, they never appear together in the normative mineralogy. Trace mineral phases such as zircon [Zrn], halite [Hl], fluorite [Fr], pyrite [Pr], and thenardite [Th] can also be estimated. The introduced samples are classified according to the TAS diagram (Le Bas et al. 1986). Other diagrams accepted by the USGS are automatically plotted: normative [Ab]-[An]-[Or], [Pl]-[Ol]-[Px], [Pl]-[Opx]-[Cpx], and [Ol]-[Opx]-[Cpx] classification ternaries diagrams. shinyNORRRM also calculates many useful petrological parameters and geochemical indexes (Table 1).

Table 1 Indexes and petrological parameters calculated by shinyNORRRM

4.2 shinyNORRRM Performance

There are four files in comma-separated values (*.csv) format attached in the CRAN: (i) “Deccan”, a data collection of geochemical analyses of igneous rocks (n = 7019) with a wide compositional range from the Deccan region, India (Gard et al. 2019); (ii) “TephraKam”, a geochemical data set of igneous rocks (n = 7596) that includes chemical compositions of felsic volcanic glass in tephra and welded tuffs from the Kamchatka volcanic arc, north-western Pacific (Portnyagin et al. 2020); (iii) “IUGS”, a collection of major oxides data of representative samples of volcanic rocks (n = 37) reported by the IUGS (Le Maitre et al. 2002); and (iv) “EAP”, a data collection of igneous rocks (n = 46) from the Eastern Mexican Alkaline Province (Elizondo-Pacheco et al. 2022). To demonstrate the shinyNORRRM performance, we ran our algorithm in the largest data sets. Figure 3 shows the locations of the samples from the “Deccan” and “TephraKam” data sets as well as the histograms of the differences between the sum of normative minerals and the whole-rock chemical analysis (adjusted to 100% on a volatile-free basis). The histograms are nearly symmetrically distributed ( ±) with a slight difference of about ± 0.006 (wt.%) that can be readily explained by rounding errors in the calculations of R. The accuracy in our package is similar to the results of IgRoCS (Verma and Rivera-Gómez 2013), which is the most used software to run the norm. According to its authors, it has an accuracy within three digits after the decimal point (± 0.009 wt.% but generally ± 0.002 wt.%; Verma et al. 2002). Therefore, a conclusion drawn from the results is that the app presented here achieves an absolute match between the adjusted oxide data (volatile-free) and the normative mineral weights.

Fig. 3
figure 3

Location of the rock samples from the databases a “Deccan” (n = 7019; Gard et al. 2019) and b “TephraKam” (n = 7596; Portnyagin et al. 2020), included in the package shinyNORRRM. The histograms show the differences between the sum of normative minerals (wt.%) and the whole-rock chemical analysis (wt.%, adjusted to 100% on a volatile-free basis) calculated in shinyNORRRM

We compared the normative mineral assemblages from the “IUGS” database by using shinyNORRRM and the most popular programs on the web: GCDkit (Janoušek et al. 2006), GeoPyTool (Yu et al. 2019), IgPet (Carr and Gazel 2017), IgRoCS (Verma and Rivera-Gómez 2013), JBL (Excel spreadsheet distributed by Jake Lowenstern), PetroGram (Gündüz and Asan 2021), MATNORM (Pruseth 2009b), and WinRock (GeologyNet®). The comparison of results for selected normative minerals is graphically visualized in the boxplots of Fig. 4, where the differences between the amounts (wt.%) yielded by shinyNORRRM and those obtained by other software are plotted. The numerical outputs of shinyNORRRM, compared with IgRoCS, prove that the results are consistent and reliable; only minor deviations in very few minerals attributed to random errors (rounding issues) from both software are observed. On the other hand, if we consider the interquartile range (IQR) of the normative minerals in Fig. 4, this deviation increases by approximately ± 2.5% for the rest of the programs. However, outlier values of the concentrations of some minerals (e.g., [Q], [Ab], and [Ol]) yielded up to 28 wt.% in the difference compared with our app (not shown in the scale of Fig. 4). All these discrepancies are likely due to the combination of the following aspects (which are common to most of the software circulating on the web): (i) Programs based on outdated algorithms such as those reported by Cross et al. (1902) or Kelsey (1965); (ii) Syntax errors in the source code; (iii) Unfixed bugs or the use of immature software versions; (iv) Inaccuracies in the atomic weights; (v) Usage of wrong mineral formulae in their calculations, and (vi) Recalculation of the bulk-rock chemical analyses to 100% on an anhydrous basis is omitted, including the adjustment of the Fe-oxidation ratio.

Fig. 4
figure 4

Boxplots showing the difference between the results for selected normative minerals (in wt.%) of the database “IUGS” (n = 37) acquired by shinyNORRRM and the most used programs on the web. Note: GCDKit, GeoPyTool, JBL, and MATNORM do not recalculate the geochemical analyses to 100 wt.%

For its part, shinyNORRRM owes its high-achieved accuracy to several factors. Firstly, the algorithm is based on mass balance principles (Verma et al. 2003). Also, it uses the most recent and accurate atomic and molecular weights reported in the literature (Prohaska et al. 2022). In addition, the object-oriented programming character of R reduces and manages the source code complexity, thereby avoiding bugs and compilation errors.

5 Conclusions

The CIPW Norm is a geochemical classification system that follows the current standards of the IUGS recommendations. shinyNORRRM is a free software designed to run an efficient CIPW Norm (± 0.006 wt.%), achieving highly consistent results. It is written in R environment, using native and extended code. The developers launched the program to become a universal petrological software as it runs on any current mainstream operating system. The code offers an intuitive and user-friendly interface to control the data import, selection of variables, visualization, and data export. The interface can handle large geochemical data sets of igneous rocks. Numerical outputs display the major oxides recalculated to 100 wt.% on a volatile-free basis (± 0.003), the adjustment of the Fe-oxidation ratio, and several petrological parameters and geochemical indexes. Graphical output includes the well-known TAS classification diagram and some ternary plots that classify a wide variety of igneous rocks. The package presented here is available for installation from the official repository of R (CRAN) or via GitHub. shinyNORRRM is extremely easy to use, can standardize the way of getting the CIPW Norm, and has the potential to become a powerful computational tool in igneous petrology.