shinyNORRRM: A Cross-Platform Software to Calculate the CIPW Norm

In this paper, a novelty-free software to assess an efficient CIPW Norm (± 0.006 wt.% in differences between input and output data) is presented. The package is available in the official repository for user-contributed R packages (CRAN: Comprehensive R Archive Network). The software is able to handle big data sets and considers minor and trace element compositions. The algorithm can calculate odd minerals in igneous rocks, such as cancrinite and calcite, adjust the Fe+3/Fe+2 ratio in different standard approaches, and recalculate the compositions of the rocks in an anhydrous basis (100 ± 0.003 wt.% volatile-free adjusted). Furthermore, the package calculates several petrological parameters, and the graphical outputs are displayed following IUGS scheme standards. The prime aspect of shinyNORRRM is the symbiosis of native R functions with the R package’s shiny (Web Application Framework for R) to run the norm in a user-friendly interface. shinyNORRRM can be executed in any operating system and requires no previous programming knowledge, thus promising to be the universal computational program in this matter. The output data are printed in the standard comma-separated values (*.csv) format, which is highly compatible with general spreadsheet editors. In this work, the algorithm of our program is validated using already compiled whole-rock geochemical databases.


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 lowpressure 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. 1986Verma et al. , 2002Verma 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; NOR-RRM: 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.

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(Streckeisen , 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  [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.

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·TiO 2 ] and acmite [Ac] as [Na 2 O·Fe 2 O 3 ·4SiO 2 ]. Unfortunately, modern analytical methods (e.g., X-ray fluorescence, inductively coupled plasma optical emission spectroscopy) only provide total Fe content expressed as either Fe 2 O 3 t or FeO t . This issue is partly responsible for the inaccuracy and the lack of standardization in norm computations because the Fe 2 O 3 /FeO ratio impacts the calculated abundance of several normative minerals. Thus, several authors have argued the need for adjustment of the Fe 2 O 3 /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 Fe 2 O 3 and FeO are the following: (i) Middlemost's solution (Middlemost 1989 Maitre, 1976), to solve Eq. (1) to specify oxidation ratios of volcanic rocks and Eq.
(2) to express the oxidation ratios of plutonic rocks

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. 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

shinyNORRRM Capabilities
Nowadays, our previous software, namely NORRRM, is practically obsolete and needs to be updated. shinyNORRRM includes parts of the traditional routines from NOR-RRM 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.%: SiO 2 , Al 2 O 3 , CaO, MgO, FeO, Fe 2 O 3 , MnO, Na 2 O, K 2 O, TiO 2 , P 2 O 5 , LOI), minor (as wt.%: CO 2 , SO 3 , 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 Fe 2 O 3 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 shinyNORRRM also calculates many useful petrological parameters and geochemical indexes (Table 1).

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. 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) (Duan et al. 2022) CaO* is the calcium content of silicates. CaO* = CaO-(10/3 × P 2 O 5 ). If the CaO* value is lower than Na 2 O, this adjusted CaO* is the value accepted. If the CaO* value is higher than Na 2 O, a value equivalent to Na 2 O is accepted 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 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. 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.   Fig. 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.%

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.