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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 5 04:29:18 CET 2017


Author: jedick
Date: 2017-02-05 04:29:16 +0100 (Sun, 05 Feb 2017)
New Revision: 130

Added:
   pkg/CHNOSZ/demo/buffer.R
   pkg/CHNOSZ/demo/protbuff.R
Removed:
   pkg/CHNOSZ/demo/buffer.R
   pkg/CHNOSZ/demo/nucleobase.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/examples.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/examples.Rd
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/vig.bib
Log:
anintro.Rmd: add buffers


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/DESCRIPTION	2017-02-05 03:29:16 UTC (rev 130)
@@ -1,6 +1,6 @@
 Date: 2017-02-05
 Package: CHNOSZ
-Version: 1.0.8-19
+Version: 1.0.8-20
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/examples.R
===================================================================
--- pkg/CHNOSZ/R/examples.R	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/R/examples.R	2017-02-05 03:29:16 UTC (rev 130)
@@ -30,8 +30,8 @@
 }
 
 demos <- function(which=c("sources", "NaCl", "density", 
-  "nucleobase", "ORP", "revisit", "findit",
-  "ionize", "buffer", "yeastgfp", "mosaic",
+  "ORP", "revisit", "findit",
+  "ionize", "buffer", "protbuff", "yeastgfp", "mosaic",
   "copper", "solubility", "wjd", "dehydration", "bugstab"), to.file=FALSE) {
   # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one
   for(i in 1:length(which)) {

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/demo/00Index	2017-02-05 03:29:16 UTC (rev 130)
@@ -1,12 +1,12 @@
 sources         cross-check the reference list with the thermodynamic database
 NaCl            equilibrium constant for aqueous NaCl dissociation
 density         density of H2O, inverted from IAPWS-95 equations
-nucleobase      relative stabilities of nucleobases and some amino acids
 ORP             oxidation-reduction potential of redox standards as a function of temperature
 revisit         detailed example of usage of revisit()
 findit          detailed example of usage of findit()
 ionize          ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK
-buffer          ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors)
+buffer          minerals and aqueous species as buffers of hydrogen fugacity
+protbuff        ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors)
 yeastgfp        logfO2-logaH2O diagrams for model proteins based on YeastGFP localizations
 mosaic          Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species
 copper          another example of mosaic(): complexation of copper with glycine species

Deleted: pkg/CHNOSZ/demo/buffer.R
===================================================================
--- pkg/CHNOSZ/demo/buffer.R	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/demo/buffer.R	2017-02-05 03:29:16 UTC (rev 130)
@@ -1,43 +0,0 @@
-## Buffer + ionization: Metastablilities of
-## thiol peroxidases from model bactera
-## (ECOLI, BACSU mesophile; AQUAE thermophile,
-## THIDA acidophile, BACHD alkaliphile)
-basis("CHNOS+")
-organisms <- c("ECOLI", "AQUAE", "BACSU", "BACHD", "THIDA")
-species("TPX", organisms)
-# create a buffer with our proteins in it
-mod.buffer("TPX", paste("TPX", organisms, sep="_"))
-# set up the buffered activities
-basis(c("CO2", "H2O", "NH3", "O2"), "TPX")
-a <- affinity(return.buffer=TRUE, T=50)
-basis(c("CO2", "H2O", "NH3", "O2"), as.numeric(a[1:4]))
-a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300))
-e <- equilibrate(a, normalize=TRUE)
-diagram(e, fill=NULL)
-title(main="Thiol peroxidases from bacteria")
-legend("topleft", describe.basis(thermo$basis[-6,]))
-
-## Buffer + ionization: relative stabilities
-## of E. coli sigma factors on a T-pH diagram
-# (sigma factors 24, 32, 38, 54, 70, i.e.
-# RpoE, RpoH, RpoS, RpoN, RpoD)
-proteins <- c("RPOE", "RP32", "RPOS", "RP54", "RPOD")
-basis("CHNOS+")
-basis("pH", 7.4)
-# define and set the buffer
-mod.buffer("sigma", paste(proteins, "ECOLI", sep="_"))
-basis(c("CO2", "NH3", "H2S", "O2"), "sigma")
-logact <- affinity(return.buffer=TRUE, T=25)
-# Set the activities of the basis species to constants 
-# corresponding to the buffer, and diagram the relative
-# stabilities as a function of T and pH
-basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact))
-species(paste(proteins, "ECOLI", sep="_"))
-a <- affinity(pH=c(5, 10), T=c(10, 40))
-diagram(a, normalize=FALSE, fill="heat")
-title(main="Relative stabilities of sigma factors in E. coli")
-ptext <- c(describe.property("T", 25), 
-  describe.basis(ibasis=c(2, 6), oneline=TRUE))
-btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE)
-legend("bottomleft", legend=c("preset (input values):",
-  ptext, "buffered (results):", btext), bty="n")

Added: pkg/CHNOSZ/demo/buffer.R
===================================================================
--- pkg/CHNOSZ/demo/buffer.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/buffer.R	2017-02-05 03:29:16 UTC (rev 130)
@@ -0,0 +1,32 @@
+# demos/buffer.R
+# calculate buffered activities of basis species using two methods
+# reproduces Figure 6 of Schulte and Shock, 1995 (doi:10.1007/BF01581580)
+
+b.species <- c("Fe", "CO2", "H2O", "N2", "H2", "H2S", "SiO2")
+b.state <- c("cr1", "gas", "liq", "gas", "gas", "aq", "aq")
+b.logact <- c(0, 1, 0, 0, 0, 0, 0)
+basis(b.species, b.state, b.logact)
+xlim <- c(0, 350)
+thermo.plot.new(xlim=xlim, ylim=c(-4, 4), xlab=axis.label("T"), ylab=axis.label("H2"))
+# method 1: in affinity(), assign name of buffer to basis species
+bufferline <- function(buffer, ixlab) {
+  basis("H2", buffer)
+  a <- affinity(T=xlim, P=300, return.buffer=TRUE, exceed.Ttr=TRUE)
+  lines(a$vals[[1]], a$H2, col="red", lwd=2)
+  text(a$vals[[1]][ixlab], a$H2[ixlab], buffer)
+}
+bufferline("FeFeO", 20)
+bufferline("QFM", 38)
+bufferline("PPM", 102)
+bufferline("HM", 51)
+# method 2: in diagram(), use the `what` argument
+basis("H2", 0)
+for(logact in c(-6, -10, -15)) {
+  species(c("formaldehyde", "HCN"), logact)
+  a <- affinity(T=xlim, P=300)
+  d <- diagram(a, what="H2", lty=c(3, 2), add=TRUE)
+  text(a$vals[[1]][13], mean(sapply(d$plotvals, c)[13, ]), logact)
+}
+# add legend
+legend("topright", legend = c(describe.property("P", 300), describe.basis(ibasis=c(2,4)),
+  "minerals", "formaldehyde", "HCN"), lty=c(NA, NA, NA, 1, 3, 2), col=c(NA, NA, NA, 2, 1, 1), bg="white")

Deleted: pkg/CHNOSZ/demo/nucleobase.R
===================================================================
--- pkg/CHNOSZ/demo/nucleobase.R	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/demo/nucleobase.R	2017-02-05 03:29:16 UTC (rev 130)
@@ -1,22 +0,0 @@
-## Nucleobase - Amino Acid Interaction Eh-H2O
-# for this example we try a custom basis set
-basis(c("CO2", "H2O", "glutamine", "e-", "H+"), c(-3, 0, -3, 0, -7))
-species(c("uracil", "cytosine", "adenine", "guanine",
-  "phenylalanine", "proline", "lysine", "glycine"), "aq")
-# this loaded four nucleobases and four related amino acids
-# (coded for by the homocodon triplets)
-# check out the predominance diagrams
-a.1 <- affinity(H2O=c(-5, 0, 300), Eh=c(-0.5, 0, 300))
-diagram(a.1, fill=NULL)
-# overlay a different temperature
-a.2 <- affinity(H2O=c(-5, 0, 300), Eh=c(-0.5, 0, 300), T=100)
-diagram(a.2, col="red", add=TRUE, names=NULL)
-# add title and legend
-title(main="Nucleobases and amino acids; P=Psat")
-# includes activities of basis species
-tb <- thermo$basis   
-# exclude those that are on the axes
-tb <- tb[!((rownames(tb) %in% c("e-", "H2O"))),]
-dp <- describe.property(c("T", "T"), c(25, 100))
-db <- describe.basis(tb)
-legend("bottomleft", lty=c(1, 1, NA, NA, NA), col=c("black", "red"), legend=c(dp, db))

Copied: pkg/CHNOSZ/demo/protbuff.R (from rev 129, pkg/CHNOSZ/demo/buffer.R)
===================================================================
--- pkg/CHNOSZ/demo/protbuff.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/protbuff.R	2017-02-05 03:29:16 UTC (rev 130)
@@ -0,0 +1,43 @@
+## Buffer + ionization: Metastablilities of
+## thiol peroxidases from model bactera
+## (ECOLI, BACSU mesophile; AQUAE thermophile,
+## THIDA acidophile, BACHD alkaliphile)
+basis("CHNOS+")
+organisms <- c("ECOLI", "AQUAE", "BACSU", "BACHD", "THIDA")
+species("TPX", organisms)
+# create a buffer with our proteins in it
+mod.buffer("TPX", paste("TPX", organisms, sep="_"))
+# set up the buffered activities
+basis(c("CO2", "H2O", "NH3", "O2"), "TPX")
+a <- affinity(return.buffer=TRUE, T=50)
+basis(c("CO2", "H2O", "NH3", "O2"), as.numeric(a[1:4]))
+a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300))
+e <- equilibrate(a, normalize=TRUE)
+diagram(e, fill=NULL)
+title(main="Thiol peroxidases from bacteria")
+legend("topleft", describe.basis(thermo$basis[-6,]))
+
+## Buffer + ionization: relative stabilities
+## of E. coli sigma factors on a T-pH diagram
+# (sigma factors 24, 32, 38, 54, 70, i.e.
+# RpoE, RpoH, RpoS, RpoN, RpoD)
+proteins <- c("RPOE", "RP32", "RPOS", "RP54", "RPOD")
+basis("CHNOS+")
+basis("pH", 7.4)
+# define and set the buffer
+mod.buffer("sigma", paste(proteins, "ECOLI", sep="_"))
+basis(c("CO2", "NH3", "H2S", "O2"), "sigma")
+logact <- affinity(return.buffer=TRUE, T=25)
+# Set the activities of the basis species to constants 
+# corresponding to the buffer, and diagram the relative
+# stabilities as a function of T and pH
+basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact))
+species(paste(proteins, "ECOLI", sep="_"))
+a <- affinity(pH=c(5, 10), T=c(10, 40))
+diagram(a, normalize=FALSE, fill="heat")
+title(main="Relative stabilities of sigma factors in E. coli")
+ptext <- c(describe.property("T", 25), 
+  describe.basis(ibasis=c(2, 6), oneline=TRUE))
+btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE)
+legend("bottomleft", legend=c("preset (input values):",
+  ptext, "buffered (results):", btext), bty="n")

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/inst/NEWS	2017-02-05 03:29:16 UTC (rev 130)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.0.8-19 (2017-02-05)
+CHANGES IN CHNOSZ 1.0.8-20 (2017-02-05)
 ---------------------------------------
 
 - Add "AA" as a keyword for preset species in basis() (cysteine,
@@ -22,7 +22,8 @@
   (citric acid cycle metabolites; thioester species have been kept) and
   from Dick et al., 2006 (methionine and [Met]).
 
-- Add demo bugstab.R.
+- Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R,
+  remove nucleobase.R.
 
 - Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter
   Canovas.

Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/man/examples.Rd	2017-02-05 03:29:16 UTC (rev 130)
@@ -15,8 +15,8 @@
 \usage{
   examples(do.png = FALSE)
   demos(which = c("sources", "NaCl", "density",
-    "nucleobase", "ORP", "revisit", "findit", 
-    "ionize", "buffer", "yeastgfp", "mosaic",
+    "ORP", "revisit", "findit", 
+    "ionize", "buffer", "protbuff", "yeastgfp", "mosaic",
     "copper", "solubility", "wjd", "dehydration", "bugstab"), to.file=FALSE)
 }
 
@@ -35,12 +35,12 @@
     \code{sources} \tab cross-check the reference list with the thermodynamic database \cr
     \code{NaCl} \tab equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr
     \code{density} \tab density of H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr
-    \code{nucleobase} \tab relative stabilities of nucleobases and some amino acids \cr
     \code{ORP} \tab oxidation-reduction potential of redox standards as a function of temperature \cr
     \code{revisit} \tab detailed example of usage of \code{\link{revisit}} \cr
     \code{findit} \tab detailed example of usage of \code{\link{findit}} \cr
     \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \cr
-    \code{buffer} \tab ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) \cr
+    \code{buffer} \tab  minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr
+    \code{protbuff} \tab ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) \cr
     \code{yeastgfp} \tab logfO2-logaH2O diagrams for model proteins based on YeastGFP localizations (Dick, 2009) \cr
     \code{mosaic} \tab Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr
     \code{copper} \tab another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr
@@ -63,6 +63,8 @@
   
   Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{http://dx.doi.org/10.2138/rmg.2013.75.5}
 
+  Schulte, M. D. and Shock, E. L. (1995) Thermodynamics of Strecker synthesis in hydrothermal systems. \emph{Orig. Life Evol. Biosph.} \bold{25}, 161--173. \url{http://dx.doi.org/10.1007/BF01581580}
+
   Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{°}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{http://dx.doi.org/10.1039/FT9928800803}
 
   Stumm, W. and Morgan, J. J. (1996) \emph{Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters}, John Wiley & Sons, New York, 1040 p. \url{http://www.worldcat.org/oclc/31754493}

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2017-02-05 03:29:16 UTC (rev 130)
@@ -582,12 +582,67 @@
 mosaicfun(list(O2=c(-70, 0, res)))
 ```
 
+## T-, P-, activity-transect
+
 ## Buffers
 
-## T-, P-, activity-transect
+There is one final feature of `affinity()` to notice.
+Can we go the other direction: calculate the activities of basis species from the activities of the species of interest?
+This question relates to the concept of chemical activity buffers.
+In CHNOSZ there are two ways to perform buffer calculations:
 
+1. Assign the name of a buffer (listed in `thermo$buffer`) to the basis species
+* more versatile (multiple activities can be buffered, e.g. both S<sub>2</sub> and O<sub>2</sub> by pyrite-pyrrhotite-magnetite)
+* the buffers are active in calculations of affinity of other species
+* use <span style="color:red">`mod.buffer()`</span> to change or add buffers in `thermo$buffer`
+* <span style="color:blue">`demo(buffer)`</span> uses it for mineral buffers (solid lines)
+2. Use the `what` argument of `diagram()` to solve for the activity of the indicated basis species
+* more convenient (the buffers come from the currently defined species of interest), but only a single basis species can be buffered, and it's not used in the calculation of affinity
+* <span style="color:blue">`demo(buffer)`</span> uses it for aqueous organic species as buffers (dotted and dashed lines)
 
+As an example of method 1, let's look at the pyrite-pyrrhotite-magnetite (PPM) buffer at 300 °C.
+```{marginfigure}
+For other examples, see <span style="color:blue">`?buffer`</span> and <span style="color:blue">`demo(protbuff)`</span> (hypothetical buffer made of proteins).
+```
+Without the buffer, the basis species have default activities of zero.
+Under these conditions, the minerals are not in equilibrium, as shown by their different affinities of formation:
+```{r PPM_basis, results="hide", message=FALSE}
+basis(c("FeS2", "H2S", "O2", "H2O"))
+species(c("pyrite", "magnetite"))
+species("pyrrhotite", "cr2")
+```
+```{r PPM_affinity, message=FALSE}
+unlist(affinity(T=300, P=100)$values)
+```
+```{marginfigure}
+The affinity of formation of pyrite happens to be zero because it is identical to one of the selected basis species.
+```
 
+We use `mod.buffer()` to choose the `cr2` phase of phyrrhotite, which is stable at this temperature.
+Then, we set up H<sub>2</sub>S and O<sub>2</sub> to be buffered by PPM, and inspect their buffered activities:
+```{r PPM_setup, results="hide"}
+mod.buffer("PPM", "pyrrhotite", "cr2")
+basis(c("H2S", "O2"), c("PPM", "PPM"))
+```
+```{r PPM_activities, message=FALSE}
+unlist(affinity(T=300, P=100, return.buffer=TRUE)[1:3])
+```
+
+<p>
+Et voilà! We have found log*a*<sub>H<sub>2</sub>S</sub> and log*f*<sub>O<sub>2</sub></sub> that are compatible with the coexistence of the three minerals.
+Under these conditions, the affinities of formation reactions of the minerals in the buffer are all equal to zero:
+```{r demo_buffer, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", message=FALSE, echo=FALSE, cache=TRUE}
+demo(buffer, echo=FALSE)
+```
+```{r PPM_affinity, message=FALSE}
+```
+
+Another example, based on Figure 6 of @SS95, is given in <span style="color:blue">`demo(buffer)`</span>.
+Here, values of log*f*<sub>H<sub>2</sub></sub> buffered by minerals or aqueous species are calculated using the two methods:
+```{r demo_buffer, eval=FALSE}
+```
+
+
 # Equilibration
 
 ## Getting from affinity to equilibrium
@@ -604,12 +659,18 @@
 
 ## Group additivity
 
+## Compositional analysis (ZC and nH2O)
+
 ## Sources of amino acid data
 
 ## Ionization
 
 ## Normalizing for different lengths
 
+# Modifying the database
+
+mod.obigt, mod.buffer
+
 # Functions outside of the main workflow
 
 transfer, wjd, eqdata, RH2obigt, EOSregress

Modified: pkg/CHNOSZ/vignettes/vig.bib
===================================================================
--- pkg/CHNOSZ/vignettes/vig.bib	2017-02-05 01:20:14 UTC (rev 129)
+++ pkg/CHNOSZ/vignettes/vig.bib	2017-02-05 03:29:16 UTC (rev 130)
@@ -211,6 +211,17 @@
   doi       = {10.1016/S0891-5849(01)00480-4},
 }
 
+ at Article{SS95,
+  author    = {Schulte, Mitchell D. and Shock, Everett L.},
+  journal   = {Origins of Life and Evolution of the Biosphere},
+  title     = {Thermodynamics of {S}trecker synthesis in hydrothermal systems},
+  year      = {1995},
+  volume    = {25},
+  number    = {1-3},
+  pages     = {161--173},
+  doi       = {10.1007/BF01581580},
+}
+
 @Article{SSW01,
   author    = {Schulte, Mitchell D. and Shock, Everett L. and Wood, Robert H.},
   journal   = {Geochimica et Cosmochimica Acta},



More information about the CHNOSZ-commits mailing list