[CHNOSZ-commits] r139 - in pkg/CHNOSZ: . R inst man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 10 15:51:45 CET 2017


Author: jedick
Date: 2017-02-10 15:51:45 +0100 (Fri, 10 Feb 2017)
New Revision: 139

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/basis.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/CHNOSZ-package.Rd
   pkg/CHNOSZ/man/basis.Rd
   pkg/CHNOSZ/man/extdata.Rd
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/vig.bib
Log:
anintro.Rmd: add proteins: compositional analysis


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/DESCRIPTION	2017-02-10 14:51:45 UTC (rev 139)
@@ -1,6 +1,6 @@
-Date: 2017-02-09
+Date: 2017-02-10
 Package: CHNOSZ
-Version: 1.0.8-28
+Version: 1.0.8-29
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/basis.R
===================================================================
--- pkg/CHNOSZ/R/basis.R	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/R/basis.R	2017-02-10 14:51:45 UTC (rev 139)
@@ -94,7 +94,7 @@
 # to load a preset basis definition by keyword
 preset.basis <- function(key=NULL) {
   # the available keywords
-  basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "AA")
+  basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "CEQ")
   # just list the keywords if none is specified
   if(is.null(key)) return(basis.key)
   # delete any previous basis definition

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/inst/NEWS	2017-02-10 14:51:45 UTC (rev 139)
@@ -1,64 +1,79 @@
-CHANGES IN CHNOSZ 1.0.8-28 (2017-02-09)
+CHANGES IN CHNOSZ 1.0.8-29 (2017-02-10)
 ---------------------------------------
 
-- Add "AA" as a keyword for preset species in basis() (cysteine,
-  glutamic acid, glutamine, H2O, oxygen).
+DOCUMENTATION:
 
 - Add eos-regress.Rmd vignette; update related functions.
 
-- More flexible parsing of chemical formulas for ZC() and other
-  functions; e.g. ZC(colMeans(protein.formula(1:4))) now works.
+- Replace anintro.Rnw (Sweave) with rewritten anintro.Rmd (knitr, Tufte
+  style).
 
-- subcrt() now returns 'loggam' using the common logarithm; add
-  test-nonideal.R to check for consistency between loggam and logK
-  values returned by subcrt(). This also fixes the issue previously
-  noted for the first example in ?nonideal. Thanks to David T. Wang for
-  the bug report and test.
+- Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R,
+  remove nucleobase.R.
 
+NEW DATA AND FEATURES:
+
 - OBIGT.csv: Add data for citric acid cycle metabolites from Canovas and
   Shock, 2016.
 
-- Clean up OBIGT-2.csv: remove data from Dalla-Betta and Schulte, 2009
-  (citric acid cycle metabolites; thioester species have been kept) and
-  from Dick et al., 2006 (methionine and [Met]).
+- extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a,
+  SS98_Fig5b, PM90 (all used by anintro.Rmd).
 
-- Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R,
-  remove nucleobase.R.
+- Add ZC.col() for generating a red-grey-blue color scale from
+  numeric values.
 
-- Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter
-  Canovas.
+- For the `groups` argument in diagram(), activities are multiplied
+  by the balance coefficients before the summation.
 
+- Add "CEQ" as a keyword for preset species in basis() (cysteine,
+  glutamic acid, glutamine, H2O, oxygen).
+
+- More flexible parsing of chemical formulas for ZC() and other
+  functions; e.g. `ZC(colMeans(protein.formula(1:4)))` now works.
+
 - read.fasta() extracts information from UniProt FASTA headers
   (accession, name, organism) into columns of the output data frame
   (protein, abbrv, organism).
 
-- diagram() draws smoother boundary lines (with contour(); 'lty' is
+- diagram() draws smoother boundary lines (with contour(); `lty` is
   usable), at the expense of not being precisely aligned with the grid
-  used for plotting colors. For the old behavior, use dotted=0.
+  used for plotting colors. For the old behavior, use `dotted=0`.
 
-- Remove msgout(), and replace previous calls to that function with
-  message() from base R. As a result, the messages don't appear in Sweave
-  vignettes, but can now be turned on or off easily in knitr vignettes.
+- diagram() applies formatting (subscripts and superscripts) to names
+  that parse as chemical formulas; use `format.names=FALSE` to disable.
 
-- Replace anintro.Rnw (Sweave) with updated anintro.Rmd (knitr, tufte).
+- Add `...` argument to thermo.plot.new() (additional arguments for
+  par()).
 
-- diagram() applies formatting (subscripts and superscripts) to names
-  that parse as chemical formulas; use `format.names` to disable.
+- With new default arguments, thermo.axis() only plots the axis tick
+  marks and lines; this is used in diagram() to redraw the axes on
+  filled diagrams.
 
-- Add '...' argument to thermo.plot.new() (extra arguments for par()).
+CLEANUP AND BUG FIXES:
 
-- Remove HTCC1062.faa.xz.
+- subcrt() returns `loggam` using the common logarithm; add
+  test-nonideal.R to check for consistency between loggam and logK
+  values returned by subcrt(). This also fixes the issue previously
+  noted for the first example in ?nonideal. Thanks to David T. Wang for
+  the bug report and test.
 
-- Add ZC.col() for generating a red-grey-blue color scale from
-  numeric values.
+- OBIGT-2.csv: remove data for citric acid cycle metabolites from
+  Dalla-Betta and Schulte, 2009; thioester species have been kept.
 
-- For the `groups` argument in diagram(), activities are now multiplied
-  by the balance coefficients before the summation.
+- OBIGT-2.csv: remove data for methionine and [Met] from Dick et al.,
+  2006. Examples that require the old group additivity parameters
+  modify the database using: `mod.obigt("[Met]", G=-35245, H=-59310)`.
 
-- With new default arguments, thermo.axis() only plots the axis tick
-  marks and lines (useful for redrawing the axis on filled diagrams).
+- Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter
+  Canovas.
 
-- Remove the bold formatting for "A" in expr.property(); now "A" is
+- Remove msgout(), and replace previous calls to that function with
+  message() from base R. As a result, the messages don't appear in Sweave
+  vignettes, but can be turned on or off in knitr vignettes.
+
+- Remove HTCC1062.faa.xz.
+
+- Remove the bold formatting for "A" in expr.property(); "A" is
   italicized like most other uppercase letters.
 
 CHANGES IN CHNOSZ 1.0.8 (2016-05-28)

Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd
===================================================================
--- pkg/CHNOSZ/man/CHNOSZ-package.Rd	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/man/CHNOSZ-package.Rd	2017-02-10 14:51:45 UTC (rev 139)
@@ -92,9 +92,14 @@
 }
 
 \section{Acknowledgements}{
-  This package would not exist without the fearless leadership and encouragement of Professor Harold C. Helgeson. Hal and his associates are in some way responsible for many of the equations and data contained in this package. A direct contribution of code is the file \code{H2O92D.f}, taken from the SUPCRT92 distribution, with only cosmetic modifications (masking of WRITE and STOP statements) made for compatibility with an \R environment. The revised Helgeson-Kirkham-Flowers equations of state are used in this package, together with the thermodynamic properties and parameters for many species taken from numerous papers coauthored by Helgeson.
+  This package would not exist without the leadership and encouragement of Professor Harold C. Helgeson.
+  Hal and his associates are in some way responsible for many of the equations and data contained in this package.
+  A direct contribution of code is the file \code{H2O92D.f}, taken from the SUPCRT92 distribution, with minor modifications (masking of WRITE and STOP statements) made for compatibility with an \R environment.
+  The revised Helgeson-Kirkham-Flowers equations of state are used in this package, together with the thermodynamic properties and parameters for many species taken from numerous papers coauthored by Helgeson.
 
-  Work on this package at U.C. Berkeley from ~2003--2008 was supported by research grants solicited by HCH from the U.S. National Science Foundation and Department of Energy. In 2009--2011, the major research project stimulating development of this package at Arizona State University was funded by the National Science Foundation under grant EAR-0847616. The files in \code{extdata/bison} are excerpts of results of BLAST calculations made on the Saguaro high performance computer at ASU. 
+  Work on this package at U.C. Berkeley from ~2003--2008 was supported by research grants to HCH from the U.S. National Science Foundation and Department of Energy.
+  In 2009--2011, development of this package was based upon work supported by the National Science Foundation under grant EAR-0847616.
+  The files in \code{extdata/bison} are excerpts of results of BLAST calculations made on the Saguaro high performance computer at ASU. 
 }
 
 \section{Known Bugs}{

Modified: pkg/CHNOSZ/man/basis.Rd
===================================================================
--- pkg/CHNOSZ/man/basis.Rd	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/man/basis.Rd	2017-02-10 14:51:45 UTC (rev 139)
@@ -59,7 +59,7 @@
                         \eqn{\mathrm{NH_3}}{NH3}, \eqn{\mathrm{H_2S}}{H2S}, \eqn{\mathrm{O_2}}{O2} \cr
     \code{FeCHNOS+} \tab \eqn{\mathrm{Fe_2O_3}}{Fe2O3}, \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2O}}{H2O}, 
                          \eqn{\mathrm{NH_3}}{NH3}, \eqn{\mathrm{H_2S}}{H2S}, \eqn{\mathrm{O_2}}{O2}, \eqn{\mathrm{H^+}}{H+} \cr
-    \code{AA} \tab cysteine, glutamic acid, glutamine, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{O_2}}{O2} \cr
+    \code{CEQ} \tab cysteine, glutamic acid, glutamine, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{O_2}}{O2} \cr
   }
 
 }

Modified: pkg/CHNOSZ/man/extdata.Rd
===================================================================
--- pkg/CHNOSZ/man/extdata.Rd	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/man/extdata.Rd	2017-02-10 14:51:45 UTC (rev 139)
@@ -36,11 +36,13 @@
     \item \code{BKM60_Fig7.dat} Eh-pH values for normal, wet and waterlogged soils from Fig. 7 of Baas Becking et al., 1960. See the \sQuote{anintro} vignette for an example that uses this file.
     \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{°}C), pH and logarithms of activity of \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2}}{H2}, \eqn{\mathrm{NH_4^+}}{NH4+}, \eqn{\mathrm{H_2S}}{H2S} and \eqn{\mathrm{CH_4}}{CH4} for mixing of seawater and hydrothermal fluid at Rainbow field (Mid-Atlantic Ridge), taken from Shock and Canovas, 2010.
     \item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \eqn{\mathrm{O_2}}{O2} and pH as a function of temperature for mixing of seawater and hydrothermal fluid, digitized from Figs. 5a and b of Shock and Schulte, 1998.
+    \item \code{rubisco.csv} UniProt IDs for Rubisco, ranges of optimal growth temperature of organisms, and domain and name of organisms, from Dick, 2014.
   }
 
   Files in \code{fasta} contain protein sequences:
   \itemize{
     \item \code{EF-Tu.aln} consists of aligned sequences (394 amino acids) of elongation factor Tu (EF-Tu). The sequences correspond to those taken from UniProtKB for ECOLI (\emph{Escherichia coli}), THETH (\emph{Thermus thermophilus}) and THEMA (\emph{Thermotoga maritima}), and reconstructed ancestral sequences taken from Gaucher et al., 2003 (maximum likelihood bacterial stem and mesophilic bacterial stem, and alternative bacterial stem). See the \sQuote{formation} vignette for an example that uses this file.
+    \item \code{rubisco.csv} Sequences of Rubisco obtained from UniProt (see Dick, 2014).
   }
 
   Files in \code{protein} contain protein composition data for model organisms.
@@ -113,6 +115,8 @@
 
   Dayhoff, M. O. and Lippincott, E. R., Eck, R. V. and Nagarajan (1967) Thermodynamic Equilibrium In Prebiological Atmospheres of C, H, O, N, P, S, and Cl. Report SP-3040, National Aeronautics and Space Administration. \url{http://ntrs.nasa.gov/search.jsp?R=19670017966}
 
+  Dick, J. M. (2014) Average oxidation state of carbon in proteins. \emph{J. R. Soc. Interface} \bold{11}, 20131095. \url{http://dx.doi.org/10.1098/rsif.2013.1095}
+
   Dick, J. M. (2016) Proteomic indicators of oxidation and hydration state in colorectal cancer. \emph{PeerJ} \bold{4}:e2238. \url{http://dx.doi.org/10.7717/peerj.2238}
 
   Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{http://dx.doi.org/10.1371/journal.pone.0022782}

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2017-02-09 16:49:54 UTC (rev 138)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2017-02-10 14:51:45 UTC (rev 139)
@@ -41,11 +41,17 @@
 knitr::knit_hooks$set(smallish.mar = function(before, options, envir) {
     if (before) par(mar = c(4.2, 4.2, 0.9, 0.9))  # smallish margins on top and right
 })
+# dpi setting
+dpi <- 100
 # use pngquant to optimize PNG images
 knitr::knit_hooks$set(pngquant = knitr::hook_pngquant)
 pngquant <- "--speed=1 --quality=0-50"
 # some frequently used HTML expressions
 logfO2 <- "log<i>f</i><sub>O<sub>2</sub></sub>"
+# use lowercase here because these tend to be variable names in the examples
+zc <- "<i>Z</i><sub>C</sub>"
+o2 <- "O<sub>2</sub>"
+h2o <- "H<sub>2</sub>O"
 ```
 
 # First steps
@@ -99,16 +105,20 @@
 
 Many functions in CHNOSZ have no side effects.
 That is, the function only returns a result; to use the result elsewhere, it can be assigned to a variable with `<-`.
+In this document (but not in the code chunks), the names of these functions are set in <span style="color:green">green text</span>.
+```{marginfigure}
+When they are mentioned, names of functions in the base and recommended packages of R are said to belong to R. Example: Use R's `plot()` to plot the points.
+```
 Major functions without side effects in CHNOSZ are:
 
-* `info()`: search for species in the thermodynamic database
-* `subcrt()`: calculate the thermodynamic properties of species and reactions
-* `affinity()`: calculate the affinities of formation reactions using given chemical activities
-* `equilibrate()`: calculate the equilibrium chemical activities of the species of interest
-* `diagram()`: plot the results
+* <span style="color:green">`info()`</span>: search for species in the thermodynamic database
+* <span style="color:green">`subcrt()`</span>: calculate the thermodynamic properties of species and reactions
+* <span style="color:green">`affinity()`</span>: calculate the affinities of formation reactions using given chemical activities
+* <span style="color:green">`equilibrate()`</span>: calculate the equilibrium chemical activities of the species of interest
+* <span style="color:green">`diagram()`</span>: plot the results
 
 Some functions in CHNOSZ do have side effects: they modify the `thermo` data object in the current R session.
-In the text (not code) of this document, the names of these functions are shown in <span style="color:red">red text</span>.
+In this document, the names of these functions are set in <span style="color:red">red text</span>.
 The major functions with side effects are:
 
 * <span style="color:red">`basis()`</span>: set the basis species and their chemical activities
@@ -128,7 +138,7 @@
 
 Some experimental functions are available:
 
-* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics.
+* (**experimental**) using <span style="color:green">`revisit()`</span> to calculate/plot summary statistics of the chemical activities of the species of interest and <span style="color:green">`findit()`</span> to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics.
 
 # Thermodynamic database and chemical formulas
 
@@ -139,9 +149,9 @@
 ```
 Where possible, data with known or suspected inconsistencies have been placed into a secondary database (`OBIGT-2.csv`) that should be regarded as experimental.
 
-## The `info()` function
+## The <span style="color:green">`info()`</span> function
 
-The `info()` function provides an interface to the thermodynamic database packaged with CHNOSZ.
+<span style="color:green">`info()`</span> provides an interface to the thermodynamic database packaged with CHNOSZ.
 Suppose you are interested in the thermodynamic properties aqueous ethylene.
 You can search for the species by name:
 ```{r info_ethylene}
@@ -154,7 +164,7 @@
 info("ethylene", "gas")
 ```
 
-Knowing that aqueous ethylene is species number 88 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters:
+Knowing that aqueous ethylene is species number 88 in the database, you can again use <span style="color:green">`info()`</span> to retrieve the set of standard molal thermodynamic properties and equations of state parameters:
 ```{r info_88}
 info(88)
 ```
@@ -167,7 +177,7 @@
 
 ## Fuzzy searches
 
-Calling `info()` with a string that does not exactly match the name of any species invokes a fuzzy search of the database:
+Calling <span style="color:green">`info()`</span> with a string that does not exactly match the name of any species invokes a fuzzy search of the database:
 ```{r width180, include=FALSE}
 options(width = 180)
 ```
@@ -187,20 +197,20 @@
 
 The messages may be useful for browsing the database, but owing to their ambiguous results, these fuzzy searches return an `NA` value for the species index.
 
-## Counting elements, chemical formulas, `ZC()`
+## Counting elements, chemical formulas, <span style="color:green">`ZC()`</span>
 
 Continuing with the example of ethylene, let's look at its chemical formula:
 ```{r info_88_formula}
 info(88)$formula
 ```
 
-We can use the `makeup()` function to count the elements in the formula, followed by `as.chemical.formula()` to return to the formula:
+We can use <span style="color:green">`makeup()`</span> to count the elements in the formula, followed by <span style="color:green">`as.chemical.formula()`</span> to return to the formula:
 ```{r makeup_88}
 makeup(88)
 as.chemical.formula(makeup(88))
 ```
 
-For organic species, a simple calculation of the average oxidation state of carbon (*Z*<sub>C</sub>) is possible given the species index, chemical formula, or elemental count:
+For organic species, a simple calculation of the average oxidation state of carbon (`r zc`) is possible given the species index, chemical formula, or elemental count:
 ```{r ZC_88}
 ZC(88)
 ZC(info(88)$formula)
@@ -209,12 +219,12 @@
 
 # Calculating thermodynamic properties
 
-To calculate the standard molal properties of species and reactions, use `subcrt()`.
+To calculate the standard molal properties of species and reactions, use <span style="color:green">`subcrt()`</span>.
 ```{marginfigure}
-The inspiration for the name `subcrt()`, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of H<sub>2</sub>O, is SUPCRT (Johnson et al., 1992).
+The inspiration for the name <span style="color:green">`subcrt()`</span>, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of `r h2o`, is SUPCRT (Johnson et al., 1992).
 ```
 <sup>[- at JOH92]</sup>
-If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species:
+If no reaction coefficients are given, <span style="color:green">`subcrt()`</span> calculates the standard molal properties of invididual species:
 ```{r subcrt_water}
 subcrt("water")
 ```
@@ -229,7 +239,7 @@
 ```
 
 A custom temperature-pressure grid can be specified.
-Here, we calculate the properties of H<sub>2</sub>O on a *T*, *P* grid in the supercritical region, with conditions grouped by pressure:
+Here, we calculate the properties of `r h2o` on a *T*, *P* grid in the supercritical region, with conditions grouped by pressure:
 ```{marginfigure}
 See also <span style="color:blue">`demo(density)`</span>.
 ```
@@ -237,12 +247,12 @@
 subcrt("water", T=c(400, 500, 600), P=c(200, 400, 600), grid="P")$out$water
 ```
 
-```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm<sup>-3</sup>) and pressure (bar) of H<sub>2</sub>O.", cache=TRUE, pngquant=pngquant}
-H2O <- subcrt("water", T=seq(0, 1000, 100), P=c(NA, seq(1, 500, 1)), grid="T")
-H2O <- H2O$out$water
-plot(H2O$P, H2O$rho, type="l")
+```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm<sup>-3</sup>) and pressure (bar) of H<sub>2</sub>O.", cache=TRUE, pngquant=pngquant}
+substuff <- subcrt("water", T=seq(0,1000,100), P=c(NA, seq(1,500,1)), grid="T")
+water <- substuff$out$water
+plot(water$P, water$rho, type="l")
 ```
-The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. `write.table()` or `plot()` for further processing:
+The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. R's `write.table()` or `plot()` for further processing:
 ```{r subcrt_water_plot, eval=FALSE}
 ```
 
@@ -259,7 +269,7 @@
 data(thermo)  ## restore default settings
 ```
 
-A related function, `convert()`, can be used to convert given values between units.
+A related function, <span style="color:green">`convert()`</span>, can be used to convert given values between units.
 Let's convert the standard Gibbs energy of aqueous methane listed in the database from cal/mol to J/mol:
 ```{r methane_G, message=FALSE}
 convert(info(info("methane"))$G, "J")
@@ -271,7 +281,7 @@
 
 ## Reaction definitions
 
-To calculate the thermodynamic properties of reactions, give the names of species, the physical states (optional), and reaction coefficients as the arguments to `subcrt()`.
+To calculate the thermodynamic properties of reactions, give the names of species, the physical states (optional), and reaction coefficients as the arguments to <span style="color:green">`subcrt()`</span>.
 Here we calculate properties for the dissolution of CO<sub>2</sub>:
 ```{marginfigure}
 Because of aqueous speciation, this doesn't give the _solubility_ of CO<sub>2</sub>.
@@ -281,9 +291,9 @@
 subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=seq(0, 250, 50))
 ```
 
-<p> <!--- needed to make the citation appear correction 20170202 -->
 In order to make a plot like Figure 18 of @MSS13, let's run more calculations and store the results.
 In addition to the reaction definition, we specify a greater number of temperature points than the default:
+
 ```{r dissolution, echo=FALSE, message=FALSE}
 T <- seq(0, 350, 10)
 CO2 <- subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=T)$out$logK
@@ -291,7 +301,7 @@
 CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T=T)$out$logK
 logK <- data.frame(T, CO2, CO, CH4)
 ```
-```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO<sub>2</sub>, CO, and CH<sub>4</sub>.", cache=TRUE, pngquant=pngquant}
+```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO<sub>2</sub>, CO, and CH<sub>4</sub>.", cache=TRUE, pngquant=pngquant}
 matplot(logK[, 1], logK[, -1], type="l", col=1, lty=1,
         xlab=axis.label("T"), ylab=axis.label("logK"))
 text(80, -1.7, expr.species("CO2"))
@@ -302,14 +312,14 @@
 ```
 
 Now we can make the plot, using R's `matplot()`.
-Here, the `axis.label()` and `expr.species()` functions of CHNOSZ are used to create formatted axis labels and chemical formulas:
+Here, <span style="color:green">`axis.label()`</span> and <span style="color:green">`expr.species()`</span> are used to create formatted axis labels and chemical formulas:
 ```{r dissolution_plot, eval=FALSE}
 ```
 
 ## Unbalanced reactions
 
 A balanced chemical reaction conserves mass.
-`subcrt()` won't stop you from running an unbalanced reaction, but it will give you a warning:
+<span style="color:green">`subcrt()`</span> won't stop you from running an unbalanced reaction, but it will give you a warning:
 ```{r subcrt_unbalanced, results="hide"}
 subcrt(c("CO2", "CH4"), c(-1, 1))
 ```
@@ -359,9 +369,9 @@
 acetoclastic <- subcrt(c("acetate", "methane"), c(-1, 1))
 ```
 
-<p>
-Use `describe.reaction()` to write the reactions on a plot:
-```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=72, out.width="100%", pngquant=pngquant}
+Use <span style="color:green">`describe.reaction()`</span> to write the reactions on a plot:
+
+```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=dpi, out.width="100%", pngquant=pngquant}
 plot(0, 0, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 5), ylim=c(5.2, -0.2))
 text(0, 0, "acetoclastic methanogenesis", adj=0)
 text(5, 1, describe.reaction(acetoclastic$reaction), adj=1)
@@ -373,21 +383,21 @@
 
 ## Affinity: not the standard state Gibbs energy
 
-Usually, `subcrt()` returns only standard state thermodynamic properties.
+Usually, <span style="color:green">`subcrt()`</span> returns only standard state thermodynamic properties.
 ```{marginfigure}
 The standard state adopted for H<sub>2</sub>O is unit activity of the pure component at any *T* and *P*.
 The standard state for aqueous species is unit activity of a hypothetical one molal solution referenced to infinite dilution at any *T* and *P*.
 ```
 Thermodynamic models often consider a non-standard state (i.e. non-unit activity).
-The activities of basis species can be modified with <span style="color:red">`basis()`</span>, and those of the other species using the `logact` argument in `subcrt()`.
+The activities of basis species can be modified with <span style="color:red">`basis()`</span>, and those of the other species using the `logact` argument in <span style="color:green">`subcrt()`</span>.
 
 Let us calculate the chemical affinity of acetoclastic methanogenesis.
 ```{marginfigure}
 The affinity is equal to the negative of the overall (non-standard) Gibbs energy change of the reaction.
 ```
 We begin by changing the energy units to Joules.
-Then, we change the state of H<sub>2</sub> and CO<sub>2</sub> in the basis from `aq` (aqueous) to `gas`, and set the logarithm of fugacity of gaseous H<sub>2</sub> and the pH, using values from @MDS_13.
-The activity of acetate and fugacity of methane, as well as temperature and pressure, are set in the call to `subcrt()`:
+Then, we change the state of `r h2o` and CO<sub>2</sub> in the basis from `aq` (aqueous) to `gas`, and set the logarithm of fugacity of gaseous H<sub>2</sub> and the pH, using values from @MDS_13.
+The activity of acetate and fugacity of methane, as well as temperature and pressure, are set in the call to <span style="color:green">`subcrt()`</span>:
 ```{r basis_mayumi, message=FALSE, results="hide"}
 E.units("J")
 basis(c("CO2", "H2"), "gas")
@@ -419,13 +429,13 @@
 }
 ```
 
-<p>
 Now we're ready to calculate and plot the affinities.
-Here, we use the `lapply()` function of R to list the results at two values of logarithm of fugacity of CO<sub>2</sub>.
+Here, we use R's `lapply()` to list the results at two values of logarithm of fugacity of CO<sub>2</sub>.
 We insert an empty reaction to get a line at zero affinity.
-`do.call(rbind, Adat)` turns the list into a data frame that can be plotted with `matplot()`.
+`do.call(rbind, Adat)` turns the list into a data frame that can be plotted with R's `matplot()`.
 There, we plot the negative affinities, equal to Gibbs energy, as shown in the plot of Mayumi et al. (2013).
-```{r methanogenesis_plot, fig.margin=TRUE, fig.width=4.1, fig.height=4.1, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Gibbs energies of acetate oxidation and methanogenesis (after Mayumi et al., 2013).", cache=TRUE, pngquant=pngquant}
+
+```{r methanogenesis_plot, fig.margin=TRUE, fig.width=4.1, fig.height=4.1, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Gibbs energies of acetate oxidation and methanogenesis (after Mayumi et al., 2013).", cache=TRUE, pngquant=pngquant}
 Adat <- lapply(c(-3, 3), function(logfCO2) {
   basis("CO2", logfCO2)
   data.frame(logfCO2,
@@ -441,7 +451,7 @@
 legend("topleft", c("acetate oxidation", "acetoclastic methanogenesis",
   "hydrogenotrophic methanogenesis"), lty=1, col=2:4)
 ```
-```{r methanogenesis_plot, echo=TRUE, eval=FALSE}
+```{r methanogenesis_plot, eval=FALSE}
 ```
 
 Let't not forget to clear the system settings, which were modified by <span style="color:red">`basis()`</span> and <span style="color:red">`E.units()`</span>, before running other calculations:
@@ -450,11 +460,11 @@
 
 ## Activity coefficients
 
-Example using `nonideal()` ...
+XXX Example using <span style="color:green">`nonideal()`</span> ...
 
-# `affinity()`, species of interest, and potential diagrams
+# <span style="color:green">`affinity()`</span>, species of interest, and potential diagrams
 
-`affinity()` offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species.
+<span style="color:green">`affinity()`</span> offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species.
 
 By *formation reaction* is meant the stoichiometric requirements for formation of one mole of any species from the basis species.
 The <span style="color:red">`species()`</span> function is used to set these *species of interest*.
@@ -471,15 +481,15 @@
 species(c("H2S", "HS-", "HSO4-", "SO4-2"))
 ```
 
-Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species:
+Now, we can use <span style="color:green">`affinity()`</span> to calculate the affinities of the formation reactions of each of the species:
 ```{marginfigure}
-The values returned by `affinity()` are dimensionless, i.e. log<sub>10</sub>(**_A_**/*RT*).
+The values returned by <span style="color:green">`affinity()`</span> are dimensionless, i.e. log<sub>10</sub>(*A*/*RT*).
 ```
 ```{r affinity}
 affinity()$values
 ```
 
-The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species.
+The same result (in energetic units) could be obtained using <span style="color:green">`subcrt()`</span>, but <span style="color:green">`affinity()`</span> has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species.
 Let's choose a set of variables commonly used in aqueous speciation diagrams: Eh and pH.
 To use Eh as a variable, the electron (`e-`) should be in the basis.
 To get the electron in there, we could use a different keyword (<span style="color:red">`basis("CHNOSe")`</span>), or swap oxygen out of the existing basis:
@@ -489,11 +499,10 @@
 
 The <span style="color:red">swap.basis()</span> changed the basis species and recalculated their activities, but preserved the species of interest.
 ```{marginfigure}
-That is, running `affinity()$values` again would give the same result.
+That is, running <span style="color:green">`affinity()`</span>`$values` again would give the same result.
 ```
 
-<p>
-```{r EhpH_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, pngquant=pngquant}
+```{r EhpH_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, pngquant=pngquant}
 a <- affinity(pH=c(0, 12), Eh=c(-1, 1))
 diagram(a, fill="heat")
 ```
@@ -501,22 +510,22 @@
 ```{r EhpH_plot, echo=1, eval=FALSE}
 ```
 
-Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram:
+Given values of affinity, the <span style="color:green">`diagram()`</span> function uses the maximum affinity method to make a potential diagram:
 ```{r EhpH_plot_echo, eval=FALSE}
 diagram(a)
 ```
 
 Note that the calculation of affinity implies a non-equilibrium reference state of equal activities of species (see above).
-Generally, then, `diagram()` gives a *potential diagram* because it shows regions of maximum affinity.
+Generally, then, <span style="color:green">`diagram()`</span> gives a *potential diagram* because it shows regions of maximum affinity.
 In systems where equilibrium is attainable, it makes sense to call this a *predominance diagram*, showing regions of maximum activity.
 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/chnosz -r 139


More information about the CHNOSZ-commits mailing list