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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 19 06:30:46 CET 2017


Author: jedick
Date: 2017-02-19 06:30:45 +0100 (Sun, 19 Feb 2017)
New Revision: 163

Added:
   pkg/CHNOSZ/vignettes/dayhoff.pdf
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/R/util.expression.R
   pkg/CHNOSZ/R/util.plot.R
   pkg/CHNOSZ/R/wjd.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/demo/NaCl.R
   pkg/CHNOSZ/demo/activity_ratios.R
   pkg/CHNOSZ/demo/buffer.R
   pkg/CHNOSZ/demo/bugstab.R
   pkg/CHNOSZ/demo/protbuff.R
   pkg/CHNOSZ/demo/solubility.R
   pkg/CHNOSZ/demo/wjd.R
   pkg/CHNOSZ/demo/yeastgfp.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/diagram.Rd
   pkg/CHNOSZ/man/examples.Rd
   pkg/CHNOSZ/man/util.plot.Rd
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/equilibrium.Rnw
   pkg/CHNOSZ/vignettes/equilibrium.lyx
   pkg/CHNOSZ/vignettes/wjd.Rnw
   pkg/CHNOSZ/vignettes/wjd.lyx
Log:
clean up demos and vignettes


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/DESCRIPTION	2017-02-19 05:30:45 UTC (rev 163)
@@ -1,6 +1,6 @@
-Date: 2017-02-18
+Date: 2017-02-19
 Package: CHNOSZ
-Version: 1.0.8-52
+Version: 1.0.8-53
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/diagram.R
===================================================================
--- pkg/CHNOSZ/R/diagram.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/R/diagram.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -12,7 +12,7 @@
   what="loga.equil", alpha=FALSE, normalize=FALSE, as.residue=FALSE, balance=NULL,
   groups=as.list(1:length(eout$values)), xrange=NULL,
   # plot dimensions
-  mar=NULL, yline=par("mgp")[1]+0.5, side=1:4,
+  mar=NULL, yline=par("mgp")[1]+0.3, side=1:4,
   # axes
   ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, 
   # sizes

Modified: pkg/CHNOSZ/R/util.expression.R
===================================================================
--- pkg/CHNOSZ/R/util.expression.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/R/util.expression.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -10,30 +10,34 @@
   # the counts of elements in the species:
   # here we don't care too much if an "element" is a real element
   # (listed in thermo$element), so we suppress warnings
-  elements <- suppressWarnings(makeup(species))
-  # where we'll put the expression
-  expr <- ""
-  # loop over elements
-  for(i in 1:length(elements)) {
-    if(names(elements)[i] != 'Z') {
-      # append the elemental symbol
-      expr <- substitute(paste(a, b), list(a=expr, b=names(elements)[i]))
-      # recover the coefficient
-      if(elements[i]==1) coeff <- "" else coeff <- elements[i]
-      # append the coefficient
-      ## subscripts within subscripts (log) are too small
-      #if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff))
-      #else expr <- substitute(a[b], list(a=expr, b=coeff))
-      expr <- substitute(a[b], list(a=expr, b=coeff))
-    } else {
-      # for charged species, don't show "Z" but do show e.g. "+2"
-      coeff <- elements[i]
-      if(coeff==-1) coeff <- "-"
-      else if(coeff==1) coeff <- "+"
-      else if(coeff > 0) coeff <- paste("+", as.character(coeff), sep="")
-      # append the coefficient (as a superscript if we're not in a log expression)
-      if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff))
-      else expr <- substitute(a^b, list(a=expr, b=coeff))
+  elements <- suppressWarnings(try(makeup(species), TRUE))
+  # if `species` can't be parsed as a chemical formula, we don't do the formula formatting
+  if(identical(class(elements), "try-error")) expr <- species
+  else {
+    # where we'll put the expression
+    expr <- ""
+    # loop over elements
+    for(i in 1:length(elements)) {
+      if(names(elements)[i] != 'Z') {
+        # append the elemental symbol
+        expr <- substitute(paste(a, b), list(a=expr, b=names(elements)[i]))
+        # recover the coefficient
+        if(elements[i]==1) coeff <- "" else coeff <- elements[i]
+        # append the coefficient
+        ## subscripts within subscripts (log) are too small
+        #if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff))
+        #else expr <- substitute(a[b], list(a=expr, b=coeff))
+        expr <- substitute(a[b], list(a=expr, b=coeff))
+      } else {
+        # for charged species, don't show "Z" but do show e.g. "+2"
+        coeff <- elements[i]
+        if(coeff==-1) coeff <- "-"
+        else if(coeff==1) coeff <- "+"
+        else if(coeff > 0) coeff <- paste("+", as.character(coeff), sep="")
+        # append the coefficient (as a superscript if we're not in a log expression)
+        if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff))
+        else expr <- substitute(a^b, list(a=expr, b=coeff))
+      }
     }
   }
   # write a designation of physical state

Modified: pkg/CHNOSZ/R/util.plot.R
===================================================================
--- pkg/CHNOSZ/R/util.plot.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/R/util.plot.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -2,7 +2,7 @@
 # Functions to create and modify plots
 
 thermo.plot.new <- function(xlim,ylim,xlab,ylab,cex=par('cex'),mar=NULL,lwd=par('lwd'),side=c(1,2,3,4),
-  mgp=c(1.5,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE,
+  mgp=c(1.7,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE,
   las=1,xline=NULL, ...) {
   # start a new plot with some customized settings
   thermo <- get("thermo")

Modified: pkg/CHNOSZ/R/wjd.R
===================================================================
--- pkg/CHNOSZ/R/wjd.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/R/wjd.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -217,7 +217,7 @@
     par(mfrow=c(length(iplot),1))
     for(i in iplot) {
       ylab <- as.expression(substitute(mu[x]/RT,list(x=colnames(ep)[i])))
-      plot(ep[,i],xlab="species combination",ylab=ylab)
+      plot(ep[,i],xlab="species combination",ylab=ylab, pch=19)
       title(main=paste("max difference (range) =",format(diff(range(ep[,i])),digits=2)))
     }
   }

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/00Index	2017-02-19 05:30:45 UTC (rev 163)
@@ -5,16 +5,16 @@
 NaCl            equilibrium constant for aqueous NaCl dissociation
 density         density of H2O, inverted from IAPWS-95 equations
 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()
+revisit         coefficient of variation of metastable equilibrium activities of proteins
+findit          minimize the standard deviation of logarithms of activities of sulfur species
 ionize          ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK
 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
+protbuff        chemical activities buffered by thiol peroxidases or sigma factors
+yeastgfp        YeastGFP locations: log fO2 - log aH2O and log a - log fO2 diagrams
 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
 solubility      solubility of calcite or CO2(gas) as a function of pH
-wjd             run.wjd() with proteins: cell periphery of yeast
+wjd             Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast
 dehydration     log K of dehydration reactions; SVG file contains tooltips and links
 bugstab         formation potential of microbial proteins in colorectal cancer
 activity_ratios mineral stability plots with activity ratios on the axes

Modified: pkg/CHNOSZ/demo/NaCl.R
===================================================================
--- pkg/CHNOSZ/demo/NaCl.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/NaCl.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -34,8 +34,7 @@
 }
 legend("bottomleft",pch=unique(expt$pch),
   legend=c(unique(expt$source),tail(expt$source,1)))
-title(main=paste("NaCl(aq) = Na+ + Cl-\n",
-  "Psat and 500-4000 bar, after Shock et al., 1992"))
+mtitle(c(describe.reaction(s$reaction), expression(italic(P)[sat]~"or 500-4000 bar, after Shock et al., 1992")))
 # where do we diverge most from experiment?
 imaxdiff <- which.max(abs(logK - expt$logK))
 stopifnot(all.equal(c("Psat", 347.7),

Modified: pkg/CHNOSZ/demo/activity_ratios.R
===================================================================
--- pkg/CHNOSZ/demo/activity_ratios.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/activity_ratios.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -15,7 +15,7 @@
 basis(c("Al+3", "pseudo-H4SiO4", "K+", "H2O", "H+", "O2"))
 species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "k-feldspar"))
 a <- affinity(H4SiO4 = c(-6, -2, res), `K+` = c(-3, 6, res))
-diagram(a, ylab = ratlab("K+"), fill = fill)
+diagram(a, ylab = ratlab("K+"), fill = fill, yline = 1.7)
 title(main = syslab(c("K2O", "Al2O3", "SiO2", "H2O")))
 legend("bottomleft", describe.property(c("T", "P"), c(25, 1)), bty = "n")
 
@@ -27,7 +27,7 @@
           "diopside", "wollastonite", "monticellite", "merwinite"))
 # calculate the chemical affinities of formation reactions
 a <- affinity("Mg+2" = c(4, 9, res), "Ca+2" = c(5, 14, res), T = 300, P = 1000)
-diagram(a, xlab = ratlab("Mg+2"), ylab = ratlab("Ca+2"), fill = fill)
+diagram(a, xlab = ratlab("Mg+2"), ylab = ratlab("Ca+2"), fill = fill, yline = 1.7)
 title(main = syslab(c("H2O", "CaO", "MgO", "SiO2")))
 legend("bottomright", describe.property(c("T", "P"), c(300, 1000)), bty = "n")
 # note: Bowers et al. use more complicated variables
@@ -39,7 +39,7 @@
 basis(c("Mg+2", "Ca+2", "SiO2", "H2O", "O2", "H+"))
 species(c("brucite", "chrysotile", "talc", "tremolite", "diopside", "akermanite"))
 a <- affinity(SiO2 = c(-10, 0, res), `Ca+2` = c(0, 20, res), T = 300)
-diagram(a, ylab = ratlab("Ca+2"), fill = fill)
+diagram(a, ylab = ratlab("Ca+2"), fill = fill, yline = 1.7)
 title(main = syslab(c("MgO", "CaO", "SiO2", "H2O")))
 legend("topright", describe.property(c("T", "P"), c(300, 85.84)), bty = "n")
 
@@ -49,7 +49,7 @@
 basis(c("Ca+2", "Al+3", "Mg+2", "SiO2", "H2O", "O2", "H+"))
 species(c("clinochlore,14a", "clinozoisite", "prehnite", "grossular"))
 a <- affinity(SiO2 = c(-5, 0, res), `Ca+2` = c(6, 11, res), T = 300, P = 500)
-diagram(a, ylab = ratlab("Ca+2"), balance = "Al+3", fill = fill)
+diagram(a, ylab = ratlab("Ca+2"), balance = "Al+3", fill = fill, yline = 1.7)
 # (Hmmm... where is clinochlore? it doesn't appear on our diagram)
 species(delete = TRUE)
 species(c("brucite", "chrysotile", "talc", "tremolite", "diopside"))

Modified: pkg/CHNOSZ/demo/buffer.R
===================================================================
--- pkg/CHNOSZ/demo/buffer.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/buffer.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -27,8 +27,10 @@
   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
+# add legends and title
 legend("topright", legend = c("minerals", "formaldehyde", "HCN"),
   lty=c(1, 3, 2), col=c(3, 1, 1), bg="white", cex=0.9)
 legend("bottomright", legend = c(describe.property("P", 300),
   describe.basis(ibasis=c(2,4))), bg="white", cex=0.9)
+title(main=paste("Mineral buffers and activities of aqueous species",
+                 "(Schulte and Shock, 1995)", sep="\n"), cex.main=0.9)

Modified: pkg/CHNOSZ/demo/bugstab.R
===================================================================
--- pkg/CHNOSZ/demo/bugstab.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/bugstab.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -45,10 +45,10 @@
   a <- affinity(O2=O2, H2O=H2O, iprotein=ip, T=37)
   names <- bugs$abbrv[ibug]
   d <- diagram(a, names=names, fill=col, as.residue=TRUE, tplot=FALSE, xlab=logfO2lab, ylab=logaH2Olab, format.names=FALSE)
-  if(i==1) title(main="fecal 16S rRNA", cex.main=1)
-  if(i==2) title(main="fecal metagenome (ZTV+14)", cex.main=1)
-  if(i==3) title(main="co-abundance groups", cex.main=1)
-  if(i==4) title(main="fecal metagenome (FLJ+15)", cex.main=1)
+  if(i==1) title(main="Fecal 16S rRNA", cex.main=1)
+  if(i==2) title(main="Fecal metagenome (ZTV+14)", cex.main=1)
+  if(i==3) title(main="Co-abundance groups", cex.main=1)
+  if(i==4) title(main="Fecal metagenome (FLJ+15)", cex.main=1)
   box()
   label.figure(LETTERS[i], yfrac=0.96, paren=FALSE, font=2, cex=1)
   # store locations of healthy bug zones
@@ -62,6 +62,6 @@
 ys <- seq(H2O[1], H2O[2], length.out=H2O[3])
 hhh <- healthbugs[[1]] + healthbugs[[2]] + healthbugs[[3]] + healthbugs[[4]]
 image(xs, ys, hhh, col=c(red, lightred, neutral, lightblue, blue), useRaster=TRUE, xlab=logfO2lab, ylab=logaH2Olab)
-title(main="cumulative stability count")
+title(main="Cumulative stability count")
 box()
 label.figure("E", yfrac=0.96, paren=FALSE, font=2, cex=1)

Modified: pkg/CHNOSZ/demo/protbuff.R
===================================================================
--- pkg/CHNOSZ/demo/protbuff.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/protbuff.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -13,9 +13,10 @@
 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, format.names=FALSE)
+fill <- ZC.col(ZC(protein.formula(species()$name)))
+diagram(e, fill=fill, format.names=FALSE)
 title(main="Thiol peroxidases from bacteria")
-legend("topleft", describe.basis(thermo$basis[-6,]))
+legend("topleft", describe.basis(thermo$basis[-6,]), bg="grey80", box.lwd=0)
 
 ## Buffer + ionization: relative stabilities
 ## of E. coli sigma factors on a T-pH diagram
@@ -33,11 +34,12 @@
 # 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", format.names=FALSE)
-title(main="Relative stabilities of sigma factors in E. coli")
+a <- affinity(pH=c(5, 10, 300), T=c(10, 40, 300))
+fill <- ZC.col(ZC(protein.formula(species()$name)))
+diagram(a, normalize=FALSE, fill=fill, format.names=FALSE)
+title(main=expression("Sigma factors in"~italic("E. coli")))
 ptext <- c(describe.property("T", 25), 
   describe.basis(ibasis=c(2, 6), oneline=TRUE))
+legend("topleft", legend=c("preset conditions:", ptext), bg="grey80", box.lwd=0)
 btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE)
-legend("bottomleft", legend=c("preset (input values):",
-  ptext, "buffered (results):", btext), bty="n")
+legend("bottomright", legend=c("buffered conditions:", btext), bg="grey80", box.lwd=0)

Modified: pkg/CHNOSZ/demo/solubility.R
===================================================================
--- pkg/CHNOSZ/demo/solubility.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/solubility.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -80,4 +80,4 @@
 lines(pHs, loga.CO3, lty=3, lwd=2)
 legend(ifelse(what=="calcite", "topright", "topleft"), lty=c(1, 1:3), lwd=c(4, 2, 2, 2), col=c("green2", rep("black", 3)),
        legend=as.expression(c("total", expr.species("CO2", state="aq"), expr.species("HCO3-"), expr.species("CO3-2"))))
-title(main=substitute(what~"solubility at"~T~degree*"C", list(what=what, T=T)))
+title(main=substitute("Solubility of"~what~"at"~T~degree*"C", list(what=what, T=T)))

Modified: pkg/CHNOSZ/demo/wjd.R
===================================================================
--- pkg/CHNOSZ/demo/wjd.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/wjd.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -1,3 +1,37 @@
+## carbon-containing compounds in prebiological atmospheres
+## Dayhoff et al., 1964 (http://dx.doi.org/10.1126/science.146.3650.1461)
+#pdf("dayhoff.pdf", width=6, height=6)
+# read formulas and Gibbs energies
+file <- system.file("extdata/thermo/DLEN67.csv", package="CHNOSZ")
+dlen <- read.csv(file, as.is=TRUE, row.names=1)
+# turn formulas into a stoichiometric matrix
+A <- i2A(dlen$formula)
+# assemble Gibbs energies/RT at 500 K
+G0.RT <- 1000 * dlen$G500 / thermo$opt$R / thermo$opt$Tr
+# a function to minimize Gibbs energy for system with 
+# given mole fraction of carbon (xC)
+min.atmos <- function(xC) {
+  # the bulk composition C:H:N:O
+  B <- c(xC, 100-40-xC, xC, 40)
+  # guess the initial composition
+  Y <- guess(A, B)
+  w <- wjd(A=A, G0.RT=G0.RT, Y=Y, P=1, imax=90, Gfrac=1e-14)
+  if(!is.near.equil(w)) cat(paste("not near equilibrium for xC=", xC, "\n"))
+  return(w)
+}
+# vary carbon content
+xCs <- seq(8, 47, 1)
+Xs <- sapply(xCs, function(xC) min.atmos(xC)$X)
+# normalize the mole numbers to mole fractions
+Xs <- t(t(Xs)/colSums(Xs))
+plot(-10, 0, xlim=c(0, 55), ylim=c(-25, 1), xlab="mole percent C", ylab="log10 mole fraction")
+for(i in 1:nrow(Xs)) lines(xCs, log10(Xs[i, ]))
+text(48, log10(Xs[, length(xCs)]), dlen$formula, adj=0)
+text(35, log10(Xs[, 27]) + 0.5, dlen$formula, adj=0)
+text(7, log10(Xs[, 1]), dlen$formula, adj=1)
+title(main="Prebiological atmospheres (Dayhoff et al., 1964)")
+#dev.off()
+
 ## run.wjd with proteins: cell periphery of yeast
 # get the proteins in the requested location
 y <- yeastgfp("cell.periphery")
@@ -28,6 +62,6 @@
 basis("CHNOS")
 bl <- basis.logact(emu)
 # make a title and legend
-title(main="relative abundances of proteins: yeast cell periphery")
+title(main="Relative abundances of proteins: yeast cell periphery")
 basis(names(bl), bl)
 legend("topleft", describe.basis(digits=2))

Modified: pkg/CHNOSZ/demo/yeastgfp.R
===================================================================
--- pkg/CHNOSZ/demo/yeastgfp.R	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/demo/yeastgfp.R	2017-02-19 05:30:45 UTC (rev 163)
@@ -30,8 +30,7 @@
 layout(matrix(c(1, 1,2:7), byrow=TRUE, nrow=4), heights=c(0.7, 3, 3, 3))
 par(mar=c(0, 0, 0, 0))
 plot.new()
-text(0.5, 0.5, paste("Subcellular proteins of S. cerevisiae,",
- "after Dick, 2009\n"), cex=1.5)
+text(0.5, 0.7, expression("Proteins in subcellular locations of"~italic("S. cerevisiae")~"(Dick, 2009)"), cex=1.5)
 text(0.5, 0.2, describe.basis(ibasis=c(1, 3, 4, 6), oneline=TRUE), cex=1.5)
 opar <- par(mar=c(3, 4, 1, 1), xpd=TRUE)
 fill <- heat.colors(length(names))
@@ -65,9 +64,7 @@
 e <- equilibrate(a, loga.balance=0, normalize=TRUE)
 mycolor <- topo.colors(length(locations))
 diagram(e, names=locations, ylim=c(-5, -3), col=mycolor, lwd=2)
-dp <- describe.property(c("T", "P"), c(25, 1))
-db <- describe.basis(ibasis=(1:6)[-5])
-legend("topright", legend=c(dp, db), bty="n")
+title(main=expression("Proteins in subcellular locations of"~italic("S. cerevisiae")))
 
 # reset thermodynamic database
 data(thermo)

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/inst/NEWS	2017-02-19 05:30:45 UTC (rev 163)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.0.8-52 (2017-02-18)
+CHANGES IN CHNOSZ 1.0.8-53 (2017-02-19)
 ---------------------------------------
 
 DOCUMENTATION:

Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/man/diagram.Rd	2017-02-19 05:30:45 UTC (rev 163)
@@ -10,7 +10,7 @@
 \usage{
   diagram(eout, what = "loga.equil", alpha = FALSE, normalize = FALSE,
     as.residue = FALSE, balance=NULL, groups=as.list(1:length(eout$values)),
-    xrange=NULL, mar=NULL, yline=par("mgp")[1]+0.5, side=1:4,
+    xrange=NULL, mar=NULL, yline=par("mgp")[1]+0.3, side=1:4,
     ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL,
     cex=par("cex"), cex.names=1, cex.axis=par("cex"),
     lty=NULL, lwd=par("lwd"), dotted=NULL,

Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/man/examples.Rd	2017-02-19 05:30:45 UTC (rev 163)
@@ -39,16 +39,16 @@
     \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{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{revisit} \tab coefficient of variation of metastable equilibrium activities of proteins \cr
+    \code{findit} \tab minimize the standard deviation of logarithms of activities of sulfur species \cr
     \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \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{protbuff} \tab chemical activities buffered by thiol peroxidases or sigma factors \cr
+    \code{yeastgfp} \tab YeastGFP locations: log fO2 - log aH2O and log a - log fO2 diagrams (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
     \code{solubility} \tab solubility of calcite (cf. Manning et al., 2013) or CO2(gas) (cf. Stumm and Morgan, 1996) \cr
-    \code{wjd} \tab run.wjd() with proteins: cell periphery of yeast \cr
+    \code{wjd} \tab Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast \cr
     \code{dehydration} \tab log K of dehydration reactions; SVG file contains tooltips and links \cr
     \code{bugstab} \tab formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr
     \code{activity_ratios} \tab mineral stability plots with activity ratios on the axes \cr

Modified: pkg/CHNOSZ/man/util.plot.Rd
===================================================================
--- pkg/CHNOSZ/man/util.plot.Rd	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/man/util.plot.Rd	2017-02-19 05:30:45 UTC (rev 163)
@@ -18,7 +18,7 @@
 \usage{
   thermo.plot.new(xlim, ylim, xlab, ylab, cex = par("cex"),
     mar = NULL, lwd = par("lwd"), side = c(1,2,3,4), 
-    mgp = c(1.5, 0.3, 0), cex.axis = par("cex"), col = par("col"),
+    mgp = c(1.7, 0.3, 0), cex.axis = par("cex"), col = par("col"),
     yline = NULL, axs = "i", do.box = TRUE, las = 1,
     xline = NULL, ...)
   thermo.axis(lab = NULL, side = 1:4, line = 1.5, cex = par("cex"),

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2017-02-19 05:30:45 UTC (rev 163)
@@ -574,6 +574,11 @@
 ```{r EhpH_plot_color, echo=TRUE, eval=FALSE}
 ```
 
+Mineral stability diagrams often depict activity ratios, e.g. log (*a*<sub>Ca<sup>+2</sup></sub>/*a*<sub>H<sup>+</sup></sub><sup>2</sup>), on one or both axes.
+The variables used for potential calculations in CHNOSZ include only a single chemical activity, e.g. log *a*<sub>Ca<sup>+2</sup></sub>.
+However, you can set pH = 0 to generate diagrams that are geometrically equivalent to those calculated using activity ratios, and use <span style="color:green">`ratlab()`</span> to make the axes labels for the ratios.
+See <span style="color:blue">`demo(activity_ratios)`</span> for some examples.
+
 ## Mosaic diagrams {#Mosaic-diagrams}
 
 If sulfur is in the basis species, then we should consider that its speciation is sensitive to Eh and pH, as shown in the preceding diagram.
@@ -633,7 +638,7 @@
 For instance, we can use H<sub>2</sub> or `r o2` in place of *e*<sup>-</sup>.
 To do that, let's write a function to swap those basis species and make a diagram.
 We use R's `do.call()` to construct the argument list for <span style="color:green">`mosaic()`</span>; this way, the name of the `newvar` argument to our function indicates the chosen variable.
-```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness.", pngquant=pngquant, timeit=timeit}
+```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system.", pngquant=pngquant, timeit=timeit}
 mosaicfun <- function(newvar, T = 200) {
   swap.basis("e-", names(newvar))
   if (names(newvar) == "O2") basis("O2", "gas")
@@ -942,11 +947,13 @@
 To make plots using different balance constraints, let's write a function that sets the `balance` argument of <span style="color:green">`diagram()`</span> and adds a title to the plot.
 The first plot is the most similar to Figure 4 of Shock (1990), except for the absence of alanine (probably due to different thermodynamic data) and the presence of some other amino acids.
 There, we set `balance = 1`, which indicates that moles of species are conserved; this is equivalent to balancing on the amino acid backbone.
-In the remaining plots, the balance is set to each of the basis species in turn (except for O<sub>2</sub>), then on volume (in the last plot).
-```{r aafun, fig.fullwidth=TRUE, fig.width=12.5, fig.height=2.5, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, results="hide", cache=TRUE, pngquant=pngquant, timeit=timeit}
+In the remaining plots, the balance is set to each of the basis species in turn (except for O<sub>2</sub>), then on volume.
+<span style="color:green">`expr.species()`</span> together with R's `substitute()` is used to make titles that include formatted chemical formulas:
+```{r aafun, fig.fullwidth=TRUE, fig.width=12.5, fig.height=2.5, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, results="hide", fig.cap="Plots of maximum affinity at 250 °C and 265 bar using different reaction balances for 20 amino acids.", cache=TRUE, pngquant=pngquant, timeit=timeit}
 aafun <- function(balance) {
   diagram(a, balance = balance, fill = col)
-  title(main = paste("balanced on", balance))
+  blab <- expr.species(balance)
+  title(main = substitute("balanced on" ~ b, list(b = blab)))
 }
 par(mfrow = c(1, 5))
 lapply(c("1", "CO2", "H2O", "N2", "volume"), aafun)
@@ -1435,7 +1442,7 @@
 ```
 
 Use the following commands to set the basis species, add the variously protonated ATP species, calculate the affinities of the formation reactions, equilibrate the system, and make a degree of formation (α) or mole fraction diagram.
-This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 and *T* = 100 °C:
+This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 M and *T* = 100 °C:
 ```{marginfigure}
 To make the code more readable, commands for plotting titles and legends are not shown.
 All of the commands are available in the source of this document.
@@ -1949,9 +1956,9 @@
 ```
 <p>
 ```{r the_end}
-   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###
-###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###
-   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###
+  ######    ##   ##    ##   ##    ######     #####  #####
+##         ##---##    ## \ ##   ##    ##     \\       //
+######    ##   ##    ##   ##    ######    #####      #####
 ```
 </p>
 

Added: pkg/CHNOSZ/vignettes/dayhoff.pdf
===================================================================
(Binary files differ)


Property changes on: pkg/CHNOSZ/vignettes/dayhoff.pdf
___________________________________________________________________
Added: svn:mime-type
   + application/pdf

Modified: pkg/CHNOSZ/vignettes/equilibrium.Rnw
===================================================================
--- pkg/CHNOSZ/vignettes/equilibrium.Rnw	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/vignettes/equilibrium.Rnw	2017-02-19 05:30:45 UTC (rev 163)
@@ -634,7 +634,7 @@
 reads ``percent GSH that has been oxidized to GSSG'', the lines
 in their figure are closer to the black lines in the figure below.
 \end{itemize}
-<<glutathione, results="hide", message=FALSE, fig.width=5, fig.height=3.5>>=
+<<glutathione, results="hide", message=FALSE, fig.width=5, fig.height=4>>=
 basis(c("GSH", "NH3", "H2S", "H2O", "H+", "e-"))
 basis("pH", 7)
 species(c("GSH", "GSSG"))
@@ -652,20 +652,7 @@
 mtext(side=2, "- - - - - - - - - - - - - - - - - - -", las=0, line=2.1, cex=0.8)
 legend("topleft", lty=1:3, legend=paste(mM, "mM GSH"))
 @
-\begin{itemize}
-\item Protein examples (with \texttt{normalize = TRUE}): 
 
-\begin{itemize}
-\item See ``Subcellular proteins'' in the vignette \emph{An introduction
-to CHNOSZ}, ``speciation diagram for ER.to.Golgi proteins'' in \texttt{?read.expr},
-and \texttt{demo(\textquotedbl{}yeastgfp\textquotedbl{})}, after \citet{Dic09}.
-\item Also see the vignette \emph{Hot-spring proteins in CHNOSZ}.
-\end{itemize}
-\item For systems of many proteins, equilibrium diagrams such as this can
-become very cluttered, and it may be desirable to use summary statistics
-to identify trends in the activities or affinities (see \texttt{revisit()}).
-\end{itemize}
-
 \subsection{Mosaic diagrams}
 
 The examples using \texttt{mosaic()} shown below are based on the

Modified: pkg/CHNOSZ/vignettes/equilibrium.lyx
===================================================================
--- pkg/CHNOSZ/vignettes/equilibrium.lyx	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/vignettes/equilibrium.lyx	2017-02-19 05:30:45 UTC (rev 163)
@@ -2763,7 +2763,7 @@
 
 \begin_layout Plain Layout
 
-<<glutathione, results="hide", message=FALSE, fig.width=5, fig.height=3.5>>=
+<<glutathione, results="hide", message=FALSE, fig.width=5, fig.height=4>>=
 \end_layout
 
 \begin_layout Plain Layout
@@ -2858,77 +2858,6 @@
 
 \end_layout
 
-\begin_layout Itemize
-Protein examples (with 
-\family typewriter
-normalize = TRUE
-\family default
-): 
-\begin_inset Separator latexpar
-\end_inset
-
-
-\end_layout
-
-\begin_deeper
-\begin_layout Itemize
-See 
-\begin_inset Quotes eld
-\end_inset
-
-Subcellular proteins
-\begin_inset Quotes erd
-\end_inset
-
- in the vignette 
-\emph on
-An introduction to CHNOSZ
-\emph default
-, 
-\begin_inset Quotes eld
-\end_inset
-
-speciation diagram for ER.to.Golgi proteins
-\begin_inset Quotes erd
-\end_inset
-
- in 
-\family typewriter
-?read.expr
-\family default
-, and 
-\family typewriter
-demo("yeastgfp")
-\family default
-, after 
-\begin_inset CommandInset citation
-LatexCommand citet
-key "Dic09"
-
-\end_inset
-
-.
-\end_layout
-
-\begin_layout Itemize
-Also see the vignette 
-\emph on
-Hot-spring proteins in CHNOSZ
-\emph default
-.
-\end_layout
-
-\end_deeper
-\begin_layout Itemize
-For systems of many proteins, equilibrium diagrams such as this can become
- very cluttered, and it may be desirable to use summary statistics to identify
- trends in the activities or affinities (see 
-\family typewriter
-revisit()
-\family default
-).
-\end_layout
-
 \begin_layout Subsection
 Mosaic diagrams
 \end_layout

Modified: pkg/CHNOSZ/vignettes/wjd.Rnw
===================================================================
--- pkg/CHNOSZ/vignettes/wjd.Rnw	2017-02-18 14:18:11 UTC (rev 162)
+++ pkg/CHNOSZ/vignettes/wjd.Rnw	2017-02-19 05:30:45 UTC (rev 163)
@@ -8,6 +8,7 @@
 \geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
 \usepackage{color}
 \usepackage{babel}
+\usepackage{graphicx}
 \usepackage[authoryear]{natbib}
 \usepackage[unicode=true,
  bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
@@ -125,15 +126,15 @@
 Then apply the function over the different numbers of iterations,
 from 0 (initial conditions) to \Sexpr{niter}, and plot the values.
 
-\setkeys{Gin}{width=1.0\textwidth}
+\setkeys{Gin}{width=0.7\textwidth}
 
 <<>>=
-<<iterplot, fig=TRUE, height=3>>=
-par(mfrow=c(1, 2))
-sa <- sapply(0:niter, iterfun, i=oX[1])
-plot(0:niter, sa, xlab="iteration", ylab=paste("x", f1))
-sa <- sapply(0:niter, iterfun, i=oX[4])
-plot(0:niter, sa, xlab="iteration", ylab=paste("x", f4))
+<<iterplot, fig=TRUE, width=6, height=2.5>>=
+par(mfrow = c(1, 2), mar = c(4.2, 4.2, .1, .1))
+sa <- sapply(0:niter, iterfun, i = oX[1])
+plot(0:niter, sa, xlab = "iteration", ylab = paste("x", f1), pch = 19)
+sa <- sapply(0:niter, iterfun, i = oX[4])
+plot(0:niter, sa, xlab = "iteration", ylab = paste("x", f4), pch = 19)
 @
 
 \setkeys{Gin}{width=1.0\textwidth}
@@ -200,25 +201,37 @@
 first look at a plot showing the results after 3 iterations.
 
 \setkeys{Gin}{width=0.6\textwidth}
+\begin{center}
 
 <<>>=
-<<w3_ep_plot, fig=TRUE>>=
+<<marmgp, echo=FALSE>>=
+par(mar = c(4.2, 4.2, 1.1, 1.1))
+par(mgp = c(2, 1, 0))
+@
+
+<<>>=
+<<w3_ep_plot, fig=TRUE, width=7, height=5>>=
+<<marmgp>>
 w3 <- wjd(imax=3)
 ep3 <- element.potentials(w3, plot.it=TRUE)
 @
 
+\end{center}
 \setkeys{Gin}{width=1.0\textwidth}
 
 Here's the plot for the default settings of \texttt{wjd()} which takes
 6 iterations:
 
 \setkeys{Gin}{width=0.6\textwidth}
+\begin{center}
 
 <<>>=
-<<w_ep_plot, fig=TRUE>>=
+<<w_ep_plot, fig=TRUE, width=7, height=5>>=
+<<marmgp>>
 ep <- element.potentials(w, plot.it=TRUE)
 @
 
+\end{center}
 \setkeys{Gin}{width=1.0\textwidth}
 
[TRUNCATED]

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


More information about the CHNOSZ-commits mailing list