[CHNOSZ-commits] r546 - in pkg/CHNOSZ: . inst vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 6 04:19:06 CEST 2020


Author: jedick
Date: 2020-07-06 04:19:04 +0200 (Mon, 06 Jul 2020)
New Revision: 546

Added:
   pkg/CHNOSZ/vignettes/equilibrium.Rmd
Removed:
   pkg/CHNOSZ/vignettes/equilibrium.Rnw
   pkg/CHNOSZ/vignettes/equilibrium.lyx
   pkg/CHNOSZ/vignettes/vig.css
Modified:
   pkg/CHNOSZ/.Rbuildignore
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/eos-regress.Rmd
Log:
Convert equilibrium.Rnw to equilibrium.Rmd (first steps)


Modified: pkg/CHNOSZ/.Rbuildignore
===================================================================
--- pkg/CHNOSZ/.Rbuildignore	2020-07-05 08:04:45 UTC (rev 545)
+++ pkg/CHNOSZ/.Rbuildignore	2020-07-06 02:19:04 UTC (rev 546)
@@ -1 +1,2 @@
 vignettes/.*.html
+vignettes/clean.sh

Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-07-05 08:04:45 UTC (rev 545)
+++ pkg/CHNOSZ/DESCRIPTION	2020-07-06 02:19:04 UTC (rev 546)
@@ -1,6 +1,6 @@
 Date: 2020-07-05
 Package: CHNOSZ
-Version: 1.3.6-20
+Version: 1.3.6-21
 Title: Thermodynamic Calculations and Diagrams for Geochemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2020-07-05 08:04:45 UTC (rev 545)
+++ pkg/CHNOSZ/inst/NEWS	2020-07-06 02:19:04 UTC (rev 546)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.3.6-20 (2020-07-05)
+CHANGES IN CHNOSZ 1.3.6-21 (2020-07-06)
 ---------------------------------------
 
 MAJOR CHANGES
@@ -45,6 +45,8 @@
 - Revise OBIGT.Rmd to reduce the size of the HTML file and make
   deep linking to individual sections work.
 
+- Work in progress: convert equilibrium.Rnw to equilibrium.Rmd.
+
 CHANGES TO FUNCTIONS
 
 - subcrt(): change 'action.unbalanced' argument to 'autobalance',
@@ -59,6 +61,11 @@
 
 - Change thermo$... to thermo()$... in messages and comments.
 
+BUG FIXES
+
+- Fix palply.Rd for new warning "Non-file package-anchored link(s) in
+  documentation object" in R CMD check.
+
 TODO
 
 - TODO: fix error in expr.species("AsO4---")
@@ -69,10 +76,10 @@
 
 - TODO: get arsenopyrite from Perfetti et al., 2008
 
-- TODO: convert equilibrium.Rnw to equilibrium.Rmd
-
 - TODO: make separate directories for default and optional data files
 
+- TODO: add missing G and H for dickite and other minerals in SUPCRT92.csv
+
 CHANGES IN CHNOSZ 1.3.6 (2020-03-16)
 ------------------------------------
 

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2020-07-05 08:04:45 UTC (rev 545)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2020-07-06 02:19:04 UTC (rev 546)
@@ -5,7 +5,6 @@
 output:
   tufte::tufte_html:
     tufte_features: ["background"]
-    css: "vig.css"
     toc: true
     mathjax: null
   tufte::tufte_handout:
@@ -23,6 +22,23 @@
 csl: elementa.csl
 ---
 
+<style>
+html { 
+  font-size: 14px;
+}
+body {
+  font-family: ‘Times New Roman’, Times, serif;
+}
+li {
+  padding: 0.25rem 0;
+}
+/* zero margin around pre blocks (looks more like R console output) */
+pre {
+  margin-top: 0;
+  margin-bottom: 0;
+}
+</style>
+
 ```{r options, include=FALSE}
 options(width = 80)
 options(digits = 6)
@@ -897,9 +913,6 @@
 ## Getting from affinity to equilibrium
 
 The <span style="color:green">`equilibrate()`</span> function in CHNOSZ automatically chooses between two methods for calculating equilibrium.
-```{marginfigure}
-For more information, see the vignette [<span style="color:blue">*Equilibrium in CHNOSZ*</span>](equilibrium.pdf).
-```
 The method based on the Boltzmann equation is fast, but is applicable only to systems where the coefficient on the balanced basis species in each of the formation reactions is one.
 The reaction-matrix method is slower, but can be applied to systems were the balanced basis species has reaction coefficients other than one.
 
@@ -1505,9 +1518,6 @@
 However, there is an additional consideration: owing to the large size of proteins compared to the basis species, the distribution of *proteins* in metastable equilibrium has many orders of magnitude separation between the activities of the dominant and less-dominant proteins.
 The metastable coexistence of the *residues* (i.e. per-residue formulas, or residue equivalents) of the same proteins spans a much smaller range of chemical activities.
 In CHNOSZ, the calculation of metastable equilibrium activities of the residue equivalents is referred to as *normalization*.
-```{marginfigure}
-See the vignette [<span style="color:blue">*Equilibrium in CHNOSZ*</span>](equilibrium.pdf) for other examples using normalization.
-```
 
 To take an example, let's look at the metastable equilibrium distribution of selected proteins in the ER-to-Golgi location of *S. cerevisiae* (yeast).
 This example brings some other functions we haven't seen yet: <span style="color:green">`unitize()`</span> and <span style="color:green">`revisit()`</span>.

Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/eos-regress.Rmd	2020-07-05 08:04:45 UTC (rev 545)
+++ pkg/CHNOSZ/vignettes/eos-regress.Rmd	2020-07-06 02:19:04 UTC (rev 546)
@@ -6,7 +6,6 @@
 output:
   tufte::tufte_html:
     tufte_features: ["background"]
-    css: "vig.css"
     toc: true
     mathjax: null
     highlight: null
@@ -25,6 +24,23 @@
 csl: elementa.csl
 ---
 
+<style>
+html { 
+  font-size: 14px;
+}
+body {
+  font-family: ‘Times New Roman’, Times, serif;
+}
+li {
+  padding: 0.25rem 0;
+}
+/* zero margin around pre blocks (looks more like R console output) */
+pre {
+  margin-top: 0;
+  margin-bottom: 0;
+}
+</style>
+
 ```{r width80, include=FALSE}
 options(width = 80)
 ```

Added: pkg/CHNOSZ/vignettes/equilibrium.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/equilibrium.Rmd	                        (rev 0)
+++ pkg/CHNOSZ/vignettes/equilibrium.Rmd	2020-07-06 02:19:04 UTC (rev 546)
@@ -0,0 +1,111 @@
+---
+title: "Equilibrium in CHNOSZ"
+author: "Jeffrey M. Dick"
+output:
+  html_vignette:
+    mathjax: null
+vignette: >
+  %\VignetteIndexEntry{Equilibrium in CHNOSZ}
+  %\VignetteEngine{knitr::rmarkdown}
+  %\VignetteEncoding{UTF-8}
+bibliography: vig.bib
+csl: elementa.csl
+---
+<style>
+/* https://css-tricks.com/hash-tag-links-padding/ */
+a.anchor::before {
+  display: block;
+  content: " ";
+  margin-top: -190px;
+  height: 190px;
+  visibility: hidden;
+  pointer-events: none;
+}
+</style>
+<script>
+function ToggleDiv(ID) {
+  var D = document.getElementById("D-" + ID);
+  var B = document.getElementById("B-" + ID);
+  if (D.style.display === "none") {
+    // open the div and change button text
+    D.style.display = "block";
+    B.innerText = "Hide code";
+  } else {
+    // close the div and change button text
+    D.style.display = "none";
+    B.innerText = "Show code";
+  }
+}
+</script>
+
+```{r CHNOSZ_reset, include=FALSE}
+library(CHNOSZ)
+reset()
+```
+
+This vignette was compiled on `r Sys.Date()` with CHNOSZ version `r sessionInfo()$otherPkgs$CHNOSZ$Version`.
+This document defines the concepts, explains the organization of functions, and provides examples of equilibrium calculations in CHNOSZ.
+
+First, some limitations.
+CHNOSZ is not a general-purpose speciation code.
+The types of equilibrium calculations it can handle are restricted to those systems that can be described as *balanced on an element*.
+For example, we can predict the speciation of Au in complexes with chloride, hydroxide, and sulfide all with specified activities.
+But we can not at the same time predict the formation of species such as NaCl(aq), which is required for a complete equilibrium model.
+
+## Concepts
+
+System
+:   Chemical system defined by formed species (referred to simply as species) and basis species, which are analogous to thermodynamic components.
+The possible species are any that are available in the [OBIGT thermodynamic database](OBIGT.html).
+
+    Species
+    :   Selection of possible chemical species for which you want to calculate relative stabilities.
+
+    Basis species
+    :   Any minimal set of possible species that can be used to balance the formation reactions of the species.
+    Additionally, in CHNOSZ the number of basis species must be equal to the number of elements.
+
+Formation reaction
+:   Chemical reaction giving the stoichiometry of basis species combined to make 1 mole of a species.
+
+Transformation reaction
+:   Any combination of two formation reactions in opposite directions (1 mole of a species reacts to form 1 mole of another species).
+
+Balancing coefficients
+:   (*n*~balance~) For a system that is balanced on one of the basis species,
+the number of moles of that basis species in the formation reaction of each of the species.
+The number can be positive or negative but not zero.
+Can also represent a virtual quantity, such as 1 (balance on moles of species) or number of amino acids in a protein sequence (balance on protein length).
+
+Speciation diagram
+:   Diagram showing the equilibrium activities of species as a function of one variable.
+
+Predominance diagram
+:   Diagram variables showing fields for species with highest equilibrium activity as a function of two variables.
+Also known as an equal activity diagram for aqueous species or stability diagram for minerals.
+
+Chemical affinity
+:   Negative of the differential of Gibbs energy of a system with respect to reaction progress.
+For a given reaction, chemical affinity is the negative of Gibbs energy of reaction: *A* = 2.303*RT*log(*K*/*Q*),
+where *K* is the equilibrium constant and *Q* is the activity quotient of species in the reaction
+(log here denotes base-10 logarithms, i.e. `log10` in R).
+
+Maximum affinity method
+:   Approach used to construct predominance diagrams not by finding the highest activity at equilibrium but by finding the highest affinity at a reference activity.
+
+    Reference activity
+    :   User-defined equal activities of species (e.g. unit activity for minerals and 10^-3^ for aqueous species).
+
+    Reference affinity
+    :   Chemical affinities of the formation reactions of the species with the reference activity.
+
+Equilibration method
+:   Calculations of the activities of species in equilibrium.
+
+    Metastable equilibrium
+    :   The condition that the affinities of all *transformation* reactions are zero.
+    Implemented with the `equilibrate()` function in CHNOSZ, which is used below.
+
+    Total equilibrium
+    :   The condition that the affinities of all *formation* reactions are zero.
+    Implemented with the `solubility()` function in CHNOSZ, which is not described here.

Deleted: pkg/CHNOSZ/vignettes/equilibrium.Rnw
===================================================================
--- pkg/CHNOSZ/vignettes/equilibrium.Rnw	2020-07-05 08:04:45 UTC (rev 545)
+++ pkg/CHNOSZ/vignettes/equilibrium.Rnw	2020-07-06 02:19:04 UTC (rev 546)
@@ -1,1078 +0,0 @@
-%% LyX 2.3.1 created this file.  For more info, see http://www.lyx.org/.
-%% Do not edit unless you really know what you are doing.
-\documentclass[english,round]{article}
-\usepackage{mathpazo}
-\renewcommand{\sfdefault}{lmss}
-\renewcommand{\ttdefault}{lmtt}
-\usepackage[T1]{fontenc}
-\usepackage[latin9]{inputenc}
-\usepackage{geometry}
-\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
-\usepackage{color}
-\usepackage{babel}
-\usepackage{amsbsy}
-\usepackage{amssymb}
-\usepackage[authoryear]{natbib}
-\usepackage[unicode=true,pdfusetitle,
- bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
- breaklinks=false,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true]
- {hyperref}
-\hypersetup{
- citecolor=magenta, urlcolor=blue}
-
-\makeatletter
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
-%\VignetteIndexEntry{Equilibrium in CHNOSZ}
-%\VignetteEngine{knitr::knitr}
-
-% so DOIs in bibliography show up as hyperlinks
-\newcommand*{\doi}[1]{\href{https://doi.org/#1}{doi: #1}}
-
-\makeatother
-
-\begin{document}
-<<setup, include=FALSE, cache=FALSE>>=
-library(knitr)
-## set global chunk options
-opts_chunk$set(fig.align='center')
-opts_chunk$set(tidy=TRUE)
-## set code/output width
-options(width=85)
-## set number of digits
-options(digits=3)
-@
-\title{Equilibrium in CHNOSZ}
-\author{Jeffrey M. Dick}
-
-\maketitle
-This document defines the concepts, explains the organization of functions,
-and provides examples of calculating equilibrium in CHNOSZ. It also
-highlights some applications of the methods (i.e. to reproduce published
-diagrams) and includes an Appendix on details of the equilibration
-calculations.
-
-\section{Concepts}
-\begin{description}
-\item [{Species~of~interest}] Chemical species for which you want to
-calculate relative stabilities.
-\item [{Basis~species}] Species in terms of which you want to write all
-formation reactions of species of interest.
-\item [{Formation~reactions}] Stoichiometric chemical reactions showing
-the mass balance requirements for formation of 1 mole of each species
-of interest from the basis species.
-\item [{Chemical~affinity}] Negative of the differential of Gibbs energy
-of a system with respect to reaction progress. For a given reaction,
-chemical affinity is the negative of Gibbs energy of reaction; $\boldsymbol{A}=2.303RT\log(K/Q)$,
-where $K$ is the equilibrium constant and $Q$ is the activity quotient
-of species in the reaction ($\log$ in this text denotes base-10 logarithms,
-i.e. \texttt{log10} in R).
-\item [{(1)~Reference~activity}] User-defined (usually equal) activities
-of species of interest.
-\item [{(1)~Reference~affinity}] ($\boldsymbol{A}_{{\it ref}}$) Chemical
-affinity of formation reaction with a reference activity of the species
-of interest.
-\item [{(1)~Maximum~affinity~method}] Comparison of reference affinities
-for given balance coefficients in order to calculate stability regions
-on a predominance diagram.
-\item [{Balance~coefficients}] ($n_{balance}$) The number of moles of
-a basis species present in the formation reaction of each of the species
-of interest. Reactions between any two species of interest then are
-``balanced'' on this basis species. Can be a quantity other than
-basis species (e.g., balance = 1, or length of amino acid sequence
-of protein).
-\item [{Predominance~diagram}] Diagram showing fields of maximal stability
-(i.e. greatest activity at equilibrium) for species of interest as
-a function of two variables (aka equal activity diagram).
-\item [{(2)~Starred~affinity}] ($\boldsymbol{A}^{*}$) Chemical affinity
-of formation reaction with unit activity of the species of interest
-(aka ``starved'' affinity because the activity of the species of
-interest drops out of $Q$).
-\item [{(2)~Total~balance~activity}] The sum of activities of this basis
-species contributed by each of the species of interest. (In Appendix:
-activity of the immobile or conserved component; $a_{\mathrm{ic}}$.)
-\item [{(2)~Equilibration~method}] Comparison of starred affinities in
-order to calculate activities of species of interest for given balance
-coefficients and total balance activity.
-\item [{Speciation~diagram}] Diagram showing the activities of species
-of interest, usually as a function of 1 variable (aka activity diagram).
-\item [{Boltzmann~distribution}] Algorithm used for the equilibration
-method when the balance coefficients are 1.
-\item [{Reaction~matrix}] Algorithm used for the equilibration method
-when the balance coefficients are not all 1.
-\item [{Normalization}] Algorithm used for large molecules such as proteins;
-chemical formulas and affinities are scaled to a similar molecular
-size (e.g. a single residue; ``residue equivalent'' in Appendix),
-activities are calculated using balance = 1, and formulas and activities
-are rescaled to the original size of the molecule.
-\item [{Mosaic}] Calculations of chemical affinities for making diagrams
-where the speciation of basis species depends on the variables.
-\end{description}
-The numbered groups above are connected with two distinct approaches
-to generating diagrams:
-\begin{enumerate}
-\item With the \textbf{maximum affinity method} for creating predominance
-diagrams, the user sets the reference activities of the species of
-interest; the program compares the reference affinities at these conditions
-to determine the most stable species (highest activity, i.e. predominant
-at equilibrium).
-\item With the \textbf{equilibration method} for creating predominance or
-activity diagrams, the user explicitly sets the total balance activity
-or the program takes it from the reference activities of the species.
-The starred affinities are used to calculate equilibrium activities
-using one of two techniques (Boltzmann distribution for balance =
-1, reaction matrix for balance $\ne$ 1).
-\end{enumerate}
-The affinities used in these calculations can be calculated using
-\texttt{affinity()}, which works with a single basis set, or with
-\texttt{mosaic()}, which uses multiple basis sets to account for basis
-species that themselves may change as a function of the variables
-of interest (e.g. ionization of carbonic acid as a function of pH).
-This document focuses primarily on the \texttt{affinity()} function;
-for more information on mosaic diagrams see the help page (type \texttt{?mosaic}
-at the R command line).
-
-Step-by-step examples of some of the calculations, particularly the
-reaction matrix algorithm, are provided in the Appendix. For further
-description of the equilibration method applied to proteins see \citet{DS13}
-(also with a derivation of energetic distance from equilibrium using
-the \textbf{starred affinity}).
-
-\section{Organization}
-
-The function sequences below assume you have already defined the basis
-species and species of interest using \texttt{basis(...)} and \texttt{species(...)}
-(ellipses here and below indicate system-specific input).
-
-Note that if \texttt{equilibrate()} or \texttt{diagram()} is called
-without an explicit \texttt{balance} argument, the balance coefficients
-will be taken from the first basis species (in the current basis definition)
-that is present in all of the species. Depending on the system, this
-may coincide either with balance = 1 or with balance $\ne$ 1. In
-the case of \texttt{normalize = TRUE} or \texttt{as.residue = TRUE},
-the balance coefficients (for the purposes of the equilibration step)
-are temporarily set to 1.
-\begin{enumerate}
-\item Maximum affinity method, balance = 1
-
-\begin{enumerate}
-\item Typical use: simple mineral/aqueous species stability comparisons
-\item Function sequence:\\
-\texttt{a <- affinity(...)}\\
-\texttt{diagram(a, balance = 1)}
-\item Algorithm: $\max\left\{ \boldsymbol{A}_{{\it ref}}\right\} $
-\end{enumerate}
-\item Equilibration method, balance = 1
-
-\begin{enumerate}
-\item Typical use: simple aqueous species activity comparisons
-\item Function sequence:\\
-\texttt{a <- affinity(...)}\\
-\texttt{e <- equilibrate(a, balance = 1)}\\
-\texttt{diagram(e)}
-\item Algorithm: Boltzmann distribution
-\end{enumerate}
-\item Maximum affinity method, balance $\ne$ 1
-
-\begin{enumerate}
-\item Typical use: mineral/aqueous species stability comparisons
-\item Function sequence:\\
-\texttt{a <- affinity(...)}~\\
-\texttt{diagram(a, balance = ...)}
-\item Algorithm: $\max\left\{ \boldsymbol{A}_{{\it ref}}/n_{balance}\right\} $
-\end{enumerate}
-\item Equilibration method, balance $\ne$ 1
-
-\begin{enumerate}
-\item Typical use: aqueous species activity comparisons
-\item Function sequence:\\
-\texttt{a <- affinity(...)}~\\
-\texttt{e <- equilibrate(a, balance = ...)}~\\
-\texttt{diagram(e)}
-\item Algorithm: Reaction matrix
-\end{enumerate}
-\item Maximum affinity method, normalize = TRUE
-
-\begin{enumerate}
-\item Typical use: protein/polymer stability comparisons
-\item Function sequence:\\
-\texttt{a <- affinity(...)}~\\
-\texttt{diagram(a, normalize = TRUE)}
-\item Algorithm: $\max\left\{ \boldsymbol{A}^{*}/n_{balance}-\log n_{balance}\right\} $
-\end{enumerate}
-\item Equilibration method, normalize = TRUE
-
-\begin{enumerate}
-\item Typical use: protein/polymer activity comparisons
-\item Function sequence:\\
-\texttt{a <- affinity(...)}~\\
-\texttt{e <- equilibrate(a, normalize = TRUE)}~\\
-\texttt{diagram(e)}
-\item Algorithm: Scale formulas and affinities to residues; Boltzmann distribution
-(balance = 1); Scale activities to proteins
-\end{enumerate}
-\end{enumerate}
-
-\section{Examples}
-
-\subsection{Amino acids}
-
-Basis species: $\mathrm{CO_{2}}$, $\mathrm{H_{2}O}$, $\mathrm{NH_{3}}$,
-$\mathrm{H_{2}S}$, $\mathrm{O_{2}}$. Species of interest: 20 amino
-acids. (Only the first few lines of the data frame of amino acid species
-are shown.)
-
-<<AAsetup>>=
-library(CHNOSZ)
-reset()
-basis("CHNOS")
-species(aminoacids(""))[1:5, ]
-@
-
-Code for making the diagrams. Function names refer to the subfigure
-labels.
-
-<<AAfigures>>=
-res <- 200
-aa <- aminoacids()
-
-aaA <- function() {
-  a <- affinity(O2=c(-90, -70, res), H2O=c(-20, 10, res))
-  diagram(a, balance=1, names=aa)
-}
-
-aaB <- function() {
-  a <- affinity(O2=c(-90, -70, 80), H2O=c(-20, 10, 80))
-  e <- equilibrate(a, balance=1)
-  diagram(e, names=aa)
-}
-
-aaC <- function() {
-  a <- affinity(O2=c(-71, -66, res), H2O=c(-8, 4, res))
-  diagram(a, balance="CO2", names=aa)
-}
-
-aaD <- function() {
-  a <- affinity(O2=c(-71, -66, 80), H2O=c(-8, 4, 80))
-  e <- equilibrate(a, balance="CO2")
-  diagram(e, names=aa)
-}
-
-aaE <- function() {
-  basis("O2", -66)
-  a <- affinity(H2O=c(-8, 4))
-  e <- equilibrate(a, balance="CO2")
-  diagram(e, ylim=c(-5, -1), names=aa)
-}
-
-aaF <- function() {
-  species(1:20, -4)
-  a <- affinity(H2O=c(-8, 4))
-  e <- equilibrate(a, balance="CO2")
-  diagram(e, ylim=c(-5, -1), names=aa)
-}
-@
-
-Note that for the plot we use the 1-letter abbreviations of the amino
-acids, unlike the full species names (\texttt{aminoacids()} is a function
-in CHNOSZ that returns their names or abbreviations).
-
-<<AAnames>>=
-AA <- aminoacids("")
-names(AA) <- aa
-AA
-@
-
-The annotated figure is shown next. The actual code used to set up
-the plots, add labels, etc. is in the source of this vignette (not
-shown in the PDF).
-
-<<showtime, include=FALSE>>=
-showtime <- function(st) {
-  # plot time in lower-right of figure region
-  f <- usrfig()
-  par(xpd=TRUE)
-  if(st[3] > 2) col <- "red" else col <- "black"
-  text(f$x[2], f$y[1], paste(round(st[3], 1), "s\n"), adj=1, col=col)
-  par(xpd=FALSE)
-}
-@
-
-<<AAplot, echo=FALSE, message=FALSE, results="hide", fig.width=13/2, fig.height=9/2, cache=TRUE>>=
-layout(t(matrix(c(1:7, 11, 8:10, 12), nrow=4)), widths=c(1, 4, 4, 4), heights=c(1, 4, 4))
-
-## row 0 (column titles)
-opar <- par(mar=c(0, 0, 0, 0))
-plot.new()
-plot.new()
-text(0.5, 0.5, "maximum affinity", cex=1.4)
-plot.new()
-text(0.5, 0.5, "equilibration", cex=1.4)
-plot.new()
-text(0.5, 0.5, "equilibration", cex=1.4)
-par(opar)
-
-## row 1 (balance = 1)
-opar <- par(mar=c(0, 0, 0, 0))
-plot.new()
-text(0.5, 0.5, "balance = 1", srt=90, cex=1.4)
-par(opar)
-# figure A
-st <- system.time(dA <- aaA())
-showtime(st)
-title(main="loga(species) = -3", cex.main=1)
-label.figure("A", col="blue", yfrac=0.9, xfrac=0.1)
-# figure B
-st <- system.time(dB <- aaB())
-showtime(st)
-title(main=paste("loga(total species) =", round(dB$loga.balance[1], 2)), cex.main=1)
-label.figure("B", col="blue", yfrac=0.9, xfrac=0.1)
-
-## row 2 (balance = nCO2)
-opar <- par(mar=c(0, 0, 0, 0))
-plot.new()
-text(0.5, 0.5, 'balance = "CO2"', srt=90, cex=1.4)
-par(opar)
-# figure C
-st <- system.time(dC <- aaC())
-showtime(st)
-title(main="loga(species) = -3", cex.main=1)
-label.figure("C", col="blue", yfrac=0.9, xfrac=0.1)
-# figure D
-st <- system.time(dD <- aaD())
-showtime(st)
-title(main=paste("loga(total CO2) =", round(dD$loga.balance[1], 2)), cex.main=1)
-label.figure("D", col="blue", yfrac=0.9, xfrac=0.1)
-
-## right (speciation at different total activity of CO2)
-par(xpd=NA)
-lines(c(-66, -64.5), c(4, 9), lty=2)
-lines(c(-66, -64.5), c(-8, -8.5), lty=2)
-par(xpd=FALSE)
-# figure E
-st <- system.time(dE <- aaE())
-showtime(st)
-title(main=paste("loga(total CO2) =", round(dE$loga.balance[1], 2)), cex.main=1)
-label.figure("E", col="blue", yfrac=0.9, xfrac=0.1)
-# figure F
-st <- system.time(dF <- aaF())
-showtime(st)
-title(main=paste("loga(total CO2) =", round(dF$loga.balance[1], 2)), cex.main=1)
-label.figure("F", col="blue", yfrac=0.9, xfrac=0.1)
-
-@
-
-Comments on the plots:
-\begin{itemize}
-\item The equal-activity lines in Figures \textcolor{blue}{A} and \textcolor{blue}{B}
-are \emph{identical}. For balance = 1, the maximum affinity method
-and the equilibration method should produce the same predominance
-diagrams. (More precisely, because balance = 1, the conditions of
-equal activity of any species of interest \textbf{are independent
-of} the actual value of that activity.)
-\item Figures \textcolor{blue}{C} and \textcolor{blue}{D} are \emph{different}.
-For balance $\ne$ 1, the maximum affinity method and the equilibration
-method will generally produce difference predominance diagrams. (Because
-balance $\ne$ 1, the conditions of equal activity of any species
-of interest \textbf{depend on} the actual value of that activity.)
-\item Both Figures \textcolor{blue}{E} and \textcolor{blue}{F} are constructed
-using the equilibration method, to calculate activities of species
-as a function of $\log a_{\mathrm{H_{2}O}}$ at $\log f_{\mathrm{O_{2}}}=-66$.
-Figure \textcolor{blue}{E} shows the results for the default settings
-($a_{\mathrm{CO_{2}}}$ is the sum of activities present in all species,
-taken from initial species activity of $10^{-3}$) and the crossing
-lines indicating equal activities \emph{are identical to the positions
-in Figure }\textcolor{blue}{\emph{D}} at $\log f_{\mathrm{O_{2}}}=-66$.
-\item Figure \textcolor{blue}{F} shows the results for a lower total activity
-of $\mathrm{CO_{2}}$. Consequently, the activities of the predominant
-species decrease from ca. $10^{-2}$ in Figure \textcolor{blue}{E}
-to ca. $10^{-3}$ in Figure \textcolor{blue}{F}. Also, the stability
-region of the smaller glycine has grown at the expense of the neighboring
-bigger amino acids, so that the crossing lines indicating equal activities
-in Figure \textcolor{blue}{F} \emph{are closer to those shown in Figure
-}\textcolor{blue}{\emph{C}} at $\log f_{\mathrm{O_{2}}}=-66$.
-\item In other words, a lower equal-activity value causes the stability
-region of the species with the smaller balance coefficient to invade
-that of the species with the larger balance coefficient.
-\item Figures \textcolor{blue}{A}, \textcolor{blue}{B}, \textcolor{blue}{C},
-and \textcolor{blue}{D} are all equal activity diagrams, but have
-different constraints on the activities:
-
-\begin{itemize}
-\item Maximum affinity method (Figures \textcolor{blue}{A}, \textcolor{blue}{C}):
-Equal activities of species set to a constant value.
-\item Equilibration method (Figures \textcolor{blue}{B}, \textcolor{blue}{D}):
-Equal activities of species determined by overall speciation of the
-system.
-\end{itemize}
-\end{itemize}
-
-\subsection{Proteins}
-
-Basis species: $\mathrm{CO_{2}}$, $\mathrm{H_{2}O}$, $\mathrm{NH_{3}}$,
-$\mathrm{H_{2}S}$, $\mathrm{O_{2}}$, $\mathrm{H^{+}}$. Species
-of interest: 6 proteins from the set of archaeal and bacterial surface
-layer proteins considered by \citet{Dic08}. 
-
-<<PRsetup, results="hide">>=
-basis("CHNOS+")
-organisms <- c("METJA", "HALJP", "METVO", "ACEKI", "GEOSE", "BACLI")
-proteins <- c(rep("CSG", 3), rep("SLAP", 3))
-species(proteins, organisms)
-@
-
-Code for the figures.
-
-<<PRfigures>>=
-prA <- function() {
-  a <- affinity(O2=c(-90, -70, 80), H2O=c(-20, 0, 80))
-  e <- equilibrate(a, balance="length", loga.balance=0)
-  diagram(e, names=organisms)
-}
-
-prB <- function() {
-  a <- affinity(O2=c(-90, -70))
-  e <- equilibrate(a, balance="length", loga.balance=0)
-  diagram(e, names=organisms, ylim=c(-5, -1))
-}
-
-prC <- function() {
-  a <- affinity(O2=c(-90, -70, res), H2O=c(-20, 0, res))
-  e <- equilibrate(a, normalize=TRUE, loga.balance=0)
-  diagram(e, names=organisms)
-}
-
-prD <- function() {
-  a <- affinity(O2=c(-90, -70))
-  e <- equilibrate(a, normalize=TRUE, loga.balance=0)
-  diagram(e, names=organisms, ylim=c(-5, -1))
-}
-
-prE <- function() {
-  a <- affinity(O2=c(-90, -70, res), H2O=c(-20, 0, res))
-  e <- equilibrate(a, as.residue=TRUE, loga.balance=0)
-  diagram(e, names=organisms)
-}
-
-prF <- function() {
-  a <- affinity(O2=c(-90, -70))
-  e <- equilibrate(a, as.residue=TRUE, loga.balance=0)
-  diagram(e, names=organisms, ylim=c(-3, 1))
-}
-@
-
-The plots follow. As before, the code used to layout the figure and
-label the plots is not shown in the PDF.
-
-<<PRplot, message=FALSE, echo=FALSE, results="hide", fig.width=13/2, fig.height=9/2, cache=TRUE>>=
-layout(t(matrix(1:12, nrow=4)), widths=c(1, 4, 4, 4), heights=c(1, 4, 4))
-
-## row 0 (column titles)
-opar <- par(mar=c(0, 0, 0, 0))
-plot.new()
-plot.new()
-text(0.5, 0.5, 'balance = "length"', cex=1.4)
-plot.new()
-text(0.5, 0.5, "normalize = TRUE\n(balance = 1)", cex=1.4)
-plot.new()
-text(0.5, 0.5, "as.residue = TRUE\n(balance = 1)", cex=1.4)
-par(opar)
-
-## row 1 (equilibrate 2D)
-opar <- par(mar=c(0, 0, 0, 0))
-plot.new()
-text(0.5, 0.5, "equilibration", srt=90, cex=1.4)
-par(opar)
-# figure A (balance = "length")
-st <- system.time(dA <- prA())
-showtime(st)
-label.figure("A", col="blue", yfrac=0.9, xfrac=0.1)
-# figure C (normalize = TRUE)
-st <- system.time(dC <- prC())
-showtime(st)
-label.figure("C", col="blue", yfrac=0.9, xfrac=0.1)
-# figure E (as.residue = TRUE)
-st <- system.time(dE <- prE())
-showtime(st)
-label.figure("E", col="blue", yfrac=0.9, xfrac=0.1)
-
-## row 2 (equilibrate 1D)
-opar <- par(mar=c(0, 0, 0, 0))
-plot.new()
-text(0.5, 0.5, "equilibration", srt=90, cex=1.4)
-par(opar)
-# figure B (balance = "length")
-st <- system.time(prB())
-showtime(st)
-label.figure("B", col="blue", yfrac=0.9, xfrac=0.1)
-# figure D (normalize = TRUE)
-st <- system.time(prD())
-showtime(st)
-label.figure("D", col="blue", yfrac=0.9, xfrac=0.1)
-# figure F (as.residue = TRUE)
-st <- system.time(prF())
-showtime(st)
-label.figure("F", col="blue", yfrac=0.9, xfrac=0.1)
-@
-
-Comments on the plots:
-\begin{itemize}
-\item All of the plots shown are calculated using the equilibration method.
-The balanced species is amino acid residues (specified by balance
-= ``length'' in Figures \textcolor{blue}{A} and \textcolor{blue}{B}.
-In the other figures, \texttt{normalize = TRUE} and \texttt{as.residue
-= TRUE} internally reset the balance to 1 after scaling the protein
-formulas to single amino acid residue equivalents). Activity of the
-balanced species (amino acid residues) is set to 1 (log activity =
-0).
-\item Figure \textcolor{blue}{B} shows that balancing on length produces
-drastic transitions between activities of the proteins. This either/or
-type behavior is a consequence of the large sizes of the balancing
-coefficients, which become exponents on the activities in the expression
-for $Q$ (or coefficients on the logarithms of activities in $\log Q$).
-\item Figure \textcolor{blue}{D} shows that coexistence of proteins with
-comparable activities can be predicted using \texttt{normalize = TRUE}.
-Here, the protein formulas and affinities are scaled down to their
-``residue equivalents'', then the equilibrium among the residue
-equivalents is calculated (with balance = 1), and the activities are
-rescaled to the original proteins. For example, a residue activity
-of 0 corresponds to $10^{-2}$ for a 100-residue protein and to $10^{-3}$
-for a 1000-residue protein. 
-\item Figures \textcolor{blue}{E} and \textcolor{blue}{F} are like \texttt{normalize
-= TRUE}, except that the rescaling to original protein size is not
-performed. Note the higher activities of the residue equivalents (Figure
-\textcolor{blue}{F}) compared to the proteins (Figure \textcolor{blue}{D}).
-\item Compare the equilibration plots above with the maximum affinity plots
-below. Here the equal activities of the proteins are intentionally
-set to a very low value: this causes a difference in the plot using
-balance = ``length'', but the second and third diagrams remain equivalent
-to those in Figures \textcolor{blue}{C} and \textcolor{blue}{E} above
-(verified by the \texttt{stopifnot} statements; \texttt{dA}, \texttt{dC}
-and \texttt{dE} refer to the diagrams above). This behavior is consistent
-with that seen in the amino acid example, where the maximum affinity
-and equilibration methods give equivalent results for balance = 1
-but different results for balance $\ne$ 1.
-\end{itemize}
-<<PRplot2, message=FALSE, results="hide", fig.width=6, fig.height=2, cache=TRUE>>=
-layout(t(matrix(1:3)))
-species(1:6, -111)
-a <- affinity(O2=c(-90, -70, res), H2O=c(-20, 0, res))
-d1 <- diagram(a, balance="length", names=organisms, main='balance = "length"')
-d2 <- diagram(a, normalize=TRUE, names=organisms, main="normalize = TRUE")
-d3 <- diagram(a, as.residue=TRUE, names=organisms, main="as.residue = TRUE")
-stopifnot(!identical(d1$predominant, dA$predominant))
-stopifnot(identical(d2$predominant, dC$predominant))
-stopifnot(identical(d3$predominant, dE$predominant))
-@
-
-With balance = ``length'', changing the equal activities to \emph{lower
-values} increases the relative stabilities of the \emph{smaller proteins},
-which is why the stability field of the larger protein from BACLI
-disappears while that of the smaller protein from METJA grows. Because
-of the drastic activity changes at the stability transitions (see
-Figure \textcolor{blue}{B} above), a large change in equal activities
-(to a minuscule activity = $10^{-111}$) is used here to demonstrate
[TRUNCATED]

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


More information about the CHNOSZ-commits mailing list