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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 19 16:38:46 CEST 2015


Author: jedick
Date: 2015-05-19 16:38:46 +0200 (Tue, 19 May 2015)
New Revision: 87

Added:
   pkg/CHNOSZ/demo/buffer.R
   pkg/CHNOSZ/demo/diagram.R
   pkg/CHNOSZ/demo/ionize.R
   pkg/CHNOSZ/demo/revisit.R
   pkg/CHNOSZ/demo/wjd.R
   pkg/CHNOSZ/demo/yeastgfp.R
Removed:
   pkg/CHNOSZ/demo/TPX.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/examples.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/demo/findit.R
   pkg/CHNOSZ/inst/CHECKLIST
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/CHNOSZ-package.Rd
   pkg/CHNOSZ/man/EOSregress.Rd
   pkg/CHNOSZ/man/IAPWS95.Rd
   pkg/CHNOSZ/man/affinity.Rd
   pkg/CHNOSZ/man/anim.Rd
   pkg/CHNOSZ/man/basis.Rd
   pkg/CHNOSZ/man/buffer.Rd
   pkg/CHNOSZ/man/data.Rd
   pkg/CHNOSZ/man/diagram.Rd
   pkg/CHNOSZ/man/eos.Rd
   pkg/CHNOSZ/man/eqdata.Rd
   pkg/CHNOSZ/man/equilibrate.Rd
   pkg/CHNOSZ/man/examples.Rd
   pkg/CHNOSZ/man/extdata.Rd
   pkg/CHNOSZ/man/findit.Rd
   pkg/CHNOSZ/man/info.Rd
   pkg/CHNOSZ/man/ionize.aa.Rd
   pkg/CHNOSZ/man/iprotein.Rd
   pkg/CHNOSZ/man/makeup.Rd
   pkg/CHNOSZ/man/more.aa.Rd
   pkg/CHNOSZ/man/mosaic.Rd
   pkg/CHNOSZ/man/objective.Rd
   pkg/CHNOSZ/man/protein.Rd
   pkg/CHNOSZ/man/protein.info.Rd
   pkg/CHNOSZ/man/read.expr.Rd
   pkg/CHNOSZ/man/revisit.Rd
   pkg/CHNOSZ/man/sideeffects.Rd
   pkg/CHNOSZ/man/species.Rd
   pkg/CHNOSZ/man/subcrt.Rd
   pkg/CHNOSZ/man/swap.basis.Rd
   pkg/CHNOSZ/man/taxonomy.Rd
   pkg/CHNOSZ/man/transfer.Rd
   pkg/CHNOSZ/man/util.affinity.Rd
   pkg/CHNOSZ/man/util.args.Rd
   pkg/CHNOSZ/man/util.array.Rd
   pkg/CHNOSZ/man/util.blast.Rd
   pkg/CHNOSZ/man/util.character.Rd
   pkg/CHNOSZ/man/util.data.Rd
   pkg/CHNOSZ/man/util.expression.Rd
   pkg/CHNOSZ/man/util.fasta.Rd
   pkg/CHNOSZ/man/util.formula.Rd
   pkg/CHNOSZ/man/util.list.Rd
   pkg/CHNOSZ/man/util.matrix.Rd
   pkg/CHNOSZ/man/util.misc.Rd
   pkg/CHNOSZ/man/util.plot.Rd
   pkg/CHNOSZ/man/util.program.Rd
   pkg/CHNOSZ/man/util.seq.Rd
   pkg/CHNOSZ/man/util.units.Rd
   pkg/CHNOSZ/man/water.Rd
   pkg/CHNOSZ/man/wjd.Rd
Log:
prepare version 1.0.5 for submission to CRAN


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/DESCRIPTION	2015-05-19 14:38:46 UTC (rev 87)
@@ -1,6 +1,6 @@
-Date: 2015-05-18
+Date: 2015-05-19
 Package: CHNOSZ
-Version: 1.0.4
+Version: 1.0.5
 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	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/R/examples.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -12,7 +12,7 @@
     "util.seq", "util.units", "taxonomy", "info", "protein.info", "hkf", "water", "subcrt",
     "makeup", "basis", "swap.basis", "species", "affinity", "util.affinity", "equil.boltzmann", 
     "diagram", "buffer", "iprotein", "protein", "ionize.aa", "more.aa", "read.expr",
-    "objective", "revisit", "findit", "transfer", "anim", "EOSregress", "wjd")
+    "objective", "revisit", "transfer", "anim", "EOSregress", "wjd")
   plot.it <- FALSE
   if(is.character(do.png))
     png(paste(do.png,"%d.png",sep=""),width=700,height=700,pointsize=18)
@@ -30,8 +30,9 @@
 }
 
 demos <- function(which=c("sources", "NaCl", "cordierite", 
-  "phosphate", "nucleobase", "orp",
-  "findit", "CO2Ac", "nonideal", "TPX", "mosaic", "solubility")) {
+  "phosphate", "nucleobase", "orp", "diagram", "revisit", "findit",
+  "CO2Ac", "nonideal", "ionize", "buffer", "yeastgfp", "mosaic",
+  "solubility", "wjd")) {
   # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one
   for(i in 1:length(which)) {
     # say something so the user sees where we are

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/demo/00Index	2015-05-19 14:38:46 UTC (rev 87)
@@ -4,9 +4,14 @@
 phosphate       phosphate speciation with pH, temperature and ionic strength
 nucleobase      relative stabilities of nucleobases and some amino acids
 orp             oxidation-reduction potential of redox standards as a function of temperature
-findit          example of findit() using log-normal distribution as an objective
+diagram         comparison of methods for calculating stability fields
+revisit         detailed example of usage of revisit()
+findit          detailed example of usage of findit()
 CO2Ac           activity of CO2 buffered by acetic acid; comparing affinity(return.buffer=TRUE) with diagram(what="CO2")
 nonideal        activity coefficient of charged species, using the IS argument of subcrt
-TPX             metastablilities of selected ionized bacterial thiol peroxidases as a chemical activity buffer
+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)
+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
 solubility      solubility of calicite or CO2(gas) as a function of pH
+wjd             run.wjd() with proteins: cell periphery of yeast

Deleted: pkg/CHNOSZ/demo/TPX.R
===================================================================
--- pkg/CHNOSZ/demo/TPX.R	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/demo/TPX.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -1,18 +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(0, 14, 200), T=c(25, 70, 200))
-e <- equilibrate(a, normalize=TRUE)
-diagram(e, fill=NULL)
-title(main="Thiol peroxidases from bacteria")
-text(0.5, 66, describe.basis(thermo$basis[-6,], oneline=TRUE), adj=0)

Added: pkg/CHNOSZ/demo/buffer.R
===================================================================
--- pkg/CHNOSZ/demo/buffer.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/buffer.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -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(0, 14, 200), T=c(25, 70, 200))
+e <- equilibrate(a, normalize=TRUE)
+diagram(e, fill=NULL)
+title(main="Thiol peroxidases from bacteria")
+text(0.5, 66, describe.basis(thermo$basis[-6,], oneline=TRUE), adj=0)
+
+## 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/diagram.R
===================================================================
--- pkg/CHNOSZ/demo/diagram.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/diagram.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -0,0 +1,17 @@
+## a case where the maximum affinity method doesn't
+## reproduce an equilibrium predominance diagram
+basis("CHNOS+")
+# this adds data for some metabolites in the TCA cycle
+# from Dalla-Betta and Schulte, 2010
+add.obigt()
+species(c("oxaloacetate-2", "malate-2", "fumarate-2",
+  "a-ketoglutarate-2", "citrate-3"))
+a <- affinity(O2=c(-80, -60), H2O=c(-5, 5))
+diagram(a, dotted=1, fill="heat")
+e <- equilibrate(a)
+diagram(e, add=TRUE, names=NULL, col="purple")
+e <- equilibrate(a, normalize=TRUE)
+diagram(e, add=TRUE, names=NULL)
+title(main=paste("maximum affinity method (fields)\n",
+  "equilibrium calculations (lines)"))
+data(thermo)

Modified: pkg/CHNOSZ/demo/findit.R
===================================================================
--- pkg/CHNOSZ/demo/findit.R	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/demo/findit.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -1,42 +1,26 @@
-opar <- par(mfrow=c(2, 2))
-# find chemical activities where metastable equilibrium activities of
-# selected proteins in P. ubique have high correlation
-# with a lognormal distribution (i.e., maximize r of q-q plot)
-f <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ")
-# search for ribosomal proteins
-g <- grep.file(f, "ribosomal")
-# read their amino acid compositions from the file
-aa <- read.fasta(f, g)
-# add these proteins to thermo$protein
-ip <- add.protein(aa)
-# load a predefined set of uncharged basis species
-# (speeds things up as we won't model protein ionization)
-basis("CHNOS")
-# plot 1: calculated logarithms of chemical activity
-# as a function of logfO2 ... a bundle of curves near logfO2 = -77
-a <- affinity(O2=c(-90, -60), iprotein=ip)
-e <- equilibrate(a, loga.balance=0, normalize=TRUE)
-d <- diagram(e, names=NULL)
-title(as.expression("Ribosomal proteins in"~italic("Pelagibacter ubique")))
-db <- describe.basis(ibasis=c(2, 1, 3))
-legend("bottomright", legend=db, bg="white")
-# plot 2: calculate q-q correlation coefficient
-# the lognormal distribution is favored near logfO2 = -77
-r <- revisit(d, "qqr")
-title(main="correlation with a normal distribution")
-text(r$xopt, r$optimum, paste(" qqr", round(r$optimum, 3), sep="="), adj=0)
-# plot 3: findit... maximize qqr as a function of activities of O2-H2O-NH3-CO2
-f1 <- findit(list(O2=c(-106, -75), H2O=c(-40, -20), CO2=c(-20, 10), NH3=c(-15, 0)),
-  "qqr", iprotein=ip, niter=12, normalize=TRUE)
-title(main="searching 4-D chemical activity space")
-# plot 4: q-q plot at the final loga O2, H2O, CO2, NH3
-# higher correlation coefficient than plot 3
-a <- affinity(iprotein=ip)
-e <- equilibrate(a, loga.balance=0, normalize=TRUE)
-qqr5 <- revisit(e, "qqr")$H
-db <- describe.basis(ibasis=c(5, 2, 1, 3))
-legend("bottomright", legend=db)
-# plot 5: trajectory of O2, H2O, CO2, NH3, and the
-# q-q correlation coefficient in the search
-#plot(f1,mar=c(2,5,1,1),mgp=c(4,1,0))
-par(opar)
+## findit() calculations for sulfur species
+basis("CHNOS+")
+basis("pH", 5)
+species(c("H2S", "S2-2", "S3-2", "S2O3-2", "S2O4-2", "S3O6-2",
+  "S5O6-2", "S2O6-2", "HSO3-", "SO2", "HSO4-"))
+# to minimize the standard deviations of the 
+# logarithms of activity the species
+objective <- "SD"
+# the variables we are interested in
+vars <- list(O2=c(-50, -15), pH=c(0, 14), T=c(275, 375))
+# optimize logfO2 at constant T and pH
+f1 <- findit(vars[1], objective, T=325, P=350, niter=3)
+title("S.D. of equilibrium log activities of sulfur species")
+# optimize logfO2 and pH at constant T
+f2 <- findit(vars[1:2], objective, T=325, P=350, res=16, niter=5)
+title("S.D. of equilibrium log activities of sulfur species")
+# optimize logfO2, pH and T (at constant P ...)
+f3 <- findit(vars, objective, P=350, res=10, niter=10)
+title("S.D. of equilibrium log activities of sulfur species")
+# the results
+print(f1.out <- sapply(f1$value, tail, 1))
+print(f2.out <- sapply(f2$value, tail, 1))
+print(f3.out <- sapply(f3$value, tail, 1))
+# with more variables, we should find a greater degree of optimization
+stopifnot(f2.out["SD"] < f1.out["SD"])
+stopifnot(f3.out["SD"] < f2.out["SD"])

Added: pkg/CHNOSZ/demo/ionize.R
===================================================================
--- pkg/CHNOSZ/demo/ionize.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/ionize.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -0,0 +1,16 @@
+## ionize.aa(): Contour plots of net charge and ionization properties of LYSC_CHICK
+aa <- ip2aa("LYSC_CHICK")
+pH <- seq(0, 14, 0.2)
+T <- seq(0, 200, 2)
+val <- expand.grid(pH=pH, T=T)
+par(mfrow=c(2, 2))
+for(X in c("Z", "A", "Cp", "V")) {
+  Y <- ionize.aa(aa, property=X,  pH=val$pH, T=val$T)
+  contour(pH, T, matrix(Y[, 1], ncol=length(T)),
+    xlab="pH", ylab=axis.label("T"))
+  title(main=axis.label(X))
+}
+par(mfrow=c(1, 1))
+pu <- par("usr")
+text(mean(pu[1:2]), sum(pu[3:4])*0.45, 
+  "additive properties of ionization of LYSC_CHICK")

Added: pkg/CHNOSZ/demo/revisit.R
===================================================================
--- pkg/CHNOSZ/demo/revisit.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/revisit.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -0,0 +1,39 @@
+## Demo for revisit(): CV of equilibrium activities of proteins in
+## Pelagibacter ubique.
+## Also shows use of grep.file(), read.fasta(), add.protein()
+f <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ")
+# what proteins to select (set to "" for all proteins)
+w <- "ribosomal"
+# locate entries whose names contain w
+j <- grep.file(f, w)
+# get the amino acid compositions of these proteins
+aa <- read.fasta(f, j)
+# add these proteins to CHNOSZ's inventory
+ip <- add.protein(aa)
+# set up a the chemical system
+basis("CHNOS+")
+# calculate affinities of formation in logfO2 space
+a <- affinity(O2=c(-85, -60), iprotein=ip)
+# show the equilibrium activities
+opar <- par(mfrow=c(2, 2))
+e <- equilibrate(a, loga.balance=0, normalize=TRUE)
+diagram(e, names=NULL)
+# make a title
+expr <- as.expression(substitute(x~y~"proteins in"~
+  italic("P. ubique"), list(x=length(j), y=w)))
+mtitle(c("Equilibrium activities of", expr))
+# show the coefficient of variation
+revisit(e, "CV")
+mtitle(c("CV of equilibrium activities of", expr))
+# calculate affinities in logfO2-logaH2O space
+a <- affinity(O2=c(-85,-65), H2O=c(-10,0), iprotein=ip)
+# show the predominances
+diagram(a, normalize=TRUE, fill="heat")
+# calculate the equilibrium activities
+e <- equilibrate(a, loga.balance=0, normalize=TRUE)
+# show the coefficient of variation
+r <- revisit(e, "CV")
+stopifnot(r$ix==37)
+stopifnot(r$iy==53)
+mtitle(c("CV of equilibrium activities of", expr))
+par(opar)

Added: pkg/CHNOSZ/demo/wjd.R
===================================================================
--- pkg/CHNOSZ/demo/wjd.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/wjd.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -0,0 +1,31 @@
+## run.wjd with proteins: cell periphery of yeast
+# get the proteins in the requested location
+y <- yeastgfp("cell.periphery")
+# get the amino acid compositions of the proteins
+aa <- more.aa(y$protein, "Sce")
+# don't use those with NA abundance or sequence
+ina <- is.na(y$abundance) | is.na(aa$chains)
+aa <- aa[!ina, ]
+# let's try normalizing the proteins to single residues
+# columns 6:25 are the actual amino acid counts
+aa.625 <- aa[, 6:25]
+aa[, 6:25] <- aa.625 / rowSums(aa.625)
+# add proteins to thermo$protein
+add.protein(aa)
+# add proteins to thermo$obigt
+iobigt <- info(paste(aa$protein, aa$organism, sep="_"))
+# use equal initial abundances, with total equal to yeastGFP abundances
+Y <- rep(mean(y$abundance[!ina]), length(y$abundance[!ina]))
+# run the Gibbs energy minimization
+w <- run.wjd(iobigt, Y=Y, imax=100)
+# make a log-log plot
+plot(log10(y$abundance[!ina]), log10(w$X), xlim=c(1.5, 5), ylim=c(1.5, 5))
+# get the element potentials (tolerating "close enough" to equilibrium)
+emu <- equil.potentials(w, tol=1e7)
+# then the logarithms of activities of the basis species
+basis("CHNOS")
+bl <- basis.logact(emu)
+# make a title and legend
+title(main="calculated vs observed abundances: yeast cell periphery")
+basis(names(bl), bl)
+legend("topleft", describe.basis(digits=2))

Added: pkg/CHNOSZ/demo/yeastgfp.R
===================================================================
--- pkg/CHNOSZ/demo/yeastgfp.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/yeastgfp.R	2015-05-19 14:38:46 UTC (rev 87)
@@ -0,0 +1,51 @@
+## Oxygen fugacity - activity of H2O predominance 
+## diagrams for proteologs for 23 YeastGFP localizations
+# use old properties of [Met] to reproduce this example
+data(thermo)
+add.obigt()
+# arranged by decreasing metastability:
+# order of this list of locations is based on the 
+# (dis)appearance of species on the current set of diagrams
+names <- c("vacuole", "early.Golgi", "ER", "lipid.particle",
+  "cell.periphery", "ambiguous", "Golgi", "mitochondrion",
+  "bud", "actin", "cytoplasm", "late.Golgi",
+  "endosome", "nucleus", "vacuolar.membrane", "punctate.composite",
+  "peroxisome", "ER.to.Golgi", "nucleolus", "spindle.pole",
+  "nuclear.periphery", "bud.neck", "microtubule")
+nloc <- c(4, 5, 3, 4, 4, 3)
+# define the system
+basis("CHNOS+")
+# get protein names and abundances in each location
+gfp <- yeastgfp(names)
+# get amino acid compositions of proteins
+aa <- more.aa(gfp$protein, "Sce")
+# calculate average amino acid compositions 
+for(i in 1:length(names)) {
+  avgaa <- aasum(aa[[i]], gfp$abundance[[i]], average=TRUE, protein=names[i])
+  add.protein(avgaa)
+}
+species(names, "Sce")
+a <- affinity(H2O=c(-5, 0, 256), O2=c(-80, -66, 256))
+# setup the plot
+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.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))
+inames <- 1:length(names)
+for(i in 1:length(nloc)) {
+  diagram(a, normalize=TRUE, names=names[inames], groups=as.list(inames),
+    fill=fill[inames], cex.axis=0.75, cex.names=1)
+  label.plot(letters[i])
+  title(main=paste(length(inames), "locations"))
+  # take out the stable species
+  inames <- inames[-(1:nloc[i])]
+}
+# return to plot defaults
+layout(matrix(1))
+par(opar)
+# reset thermodynamic database
+data(thermo)

Modified: pkg/CHNOSZ/inst/CHECKLIST
===================================================================
--- pkg/CHNOSZ/inst/CHECKLIST	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/inst/CHECKLIST	2015-05-19 14:38:46 UTC (rev 87)
@@ -41,7 +41,13 @@
 
 - clean up all TODO, XXX, etc. in Rd files (and hopefully R files too)
 
-- ensure all Rd files have \keyword{...}
-
 - update .Rinstignore with any new/deleted files
 
+- ensure all Rd files have \keyword{...} or \concept{...}
+  - keywords used are standard R keywords: package, utilities
+  - concepts are as follows:
+    - Thermodynamic data (thermo, extdata)
+    - Primary thermodynamic modeling (commonly used functions e.g. subcrt)
+    - Secondary thermodynamic modeling (less often-used functions e.g. revisit)
+    - Extra thermodynamic modeling (out-of-workflow functions e.g. transfer)
+    - Protein thermodynamic modeling (protein-specific functions e.g. ionize.aa)

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/inst/NEWS	2015-05-19 14:38:46 UTC (rev 87)
@@ -1,3 +1,19 @@
+CHANGES IN CHNOSZ 1.0.5 (2015-05-19)
+------------------------------------
+
+- Following "Writing R Extensions", remove uncommented \donttest{} code
+  from Rd files. Some examples have had \donttest{} markup removed
+  without other modification, some non-representative examples have
+  been deleted, and some longer examples have been moved to demo files.
+
+- Some previous \donttest{} examples have been moved to demos 'findit.R'
+  (replaces old demo), and to new demos 'revisit.R', 'ionize.R',
+  'buffer.R', 'wjd.R', 'yeastgfp.R', 'diagram.R'.
+
+- Rd files now use standard R \keyword{}s ('package' and 'utilities');
+  non-standard keywords have been changed to \concept{}s (see CHECKLIST
+  for description, and CHNOSZ-package.Rd for overview).
+
 CHANGES IN CHNOSZ 1.0.4 (2015-05-18)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd
===================================================================
--- pkg/CHNOSZ/man/CHNOSZ-package.Rd	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/man/CHNOSZ-package.Rd	2015-05-19 14:38:46 UTC (rev 87)
@@ -3,9 +3,21 @@
 \docType{package}
 \title{Chemical Thermodynamics and Activity Diagrams}
 \description{
-  CHNOSZ is a package for thermodynamic calculations, primarily with applications in geochemistry and biochemistry. It can be used to calculate the standard molal thermodynamic properties and chemical affinities of reactions relevant to geobiochemical processes, and to visualize the equilibrium activities of species on chemical speciation and predominance diagrams. The package can be used interactively and in batch mode, through the use of R source files containing a sequence of commands. The major features of the package are outlined below, with links to specific help topics in this document, which constitutes the primary technical description of the package. If you are a new user, the \sQuote{anintro} vignette (An introduction to CHNOSZ) may offer a more comfortable way to get started with using the package.
+CHNOSZ is a package for thermodynamic calculations, primarily with applications in geochemistry and biochemistry.
+It can be used to calculate the standard molal thermodynamic properties and chemical affinities of reactions relevant to geobiochemical processes, and to visualize the equilibrium activities of species on chemical speciation and predominance diagrams.
+The package can be used interactively and in batch mode, through the use of R source files containing a sequence of commands.
 }
 
+\section{Getting Help}{
+The major features of the package are outlined in the Overview given below, with links to specific help topics.
+If you are a new user, the \sQuote{anintro} vignette (An introduction to CHNOSZ) may offer a more comfortable way to get started with using the package.
+The help pages have been given either keywords or \dQuote{concept index entries} which are visible to \code{\link{help.search}} (aka \code{??}).
+Use \code{??primary} to browse the most commonly used functions and \code{??secondary} to see other high-level, but less often-used functions.
+\code{??protein} shows functions for working with proteins, and \code{??extra} lists functions with extra functionality (beyond the main workflow).
+For help on the thermodynamic database, use \code{??"thermodynamic data"}.
+Finally, \code{??utilities} (one of the standard \R keywords) can be used to locate utility functions in the package; these include useful tools for modifying the database, converting units, reading protein sequence files, parsing chemical formulas, etc.
+}
+
 \section{Warning}{
 All thermodynamic data and examples are provided on an as-is basis.
 It is up to you to check not only the accuracy of the data, but also the \emph{suitability of the data AND computational techniques} for your problem.
@@ -31,7 +43,7 @@
 
   \item File and internet access - read protein sequences from FASTA files, and download sequence information from UniProt (\code{\link{read.fasta}}, \code{\link{protein}}).
 
-  \item Equations of state - calculate the standard thermodynamic properties of proteins or other species in the database, and reactions between them, as a function of temperature and pressure (\code{\link{hkf}}, \code{\link{cgl}}), \code{\link{subcrt}}.
+  \item Equations of state - calculate the standard thermodynamic properties of proteins or other species in the database, and reactions between them, as a function of temperature and pressure (\code{\link{hkf}}, \code{\link{cgl}}, \code{\link{subcrt}}).
 
   \item Stoichiometry - count elements in chemical formulas of species, check and optionally correct mass balance of chemical reactions (\code{\link{makeup}}).
 
@@ -41,16 +53,16 @@
 
   \item Chemical activity - calculate the equilibrium activities of the species of interest as a function of the same variables used in the affinity calculation, using a reference state transformation (either the Boltzmann distribution or a reaction matrix approach). (\code{\link{diagram}}, \code{\link{equil.reaction}}, \code{\link{equil.boltzmann}}).
 
-  \item Buffer calculations - compute activities of basis species that are determined by a buffer of one or more species (e.g., pyrite-pyrrhotite-magnetite; acetic acid-CO2) (\code{\link{buffer}}).
-
   \item Activity diagrams - plot the equilibrium activities at a single point (as barplots), or as a function of one (species activity diagrams) or two (predominance diagrams) variables (\code{\link{diagram}}).
 
-  \item Activity statistics - calculate summary statistics for equilibrium activities of species (\code{\link{revisit}}).
+  \item Buffer calculations (\bold{experimental}) - compute activities of basis species that are determined by a buffer of one or more species (e.g., pyrite-pyrrhotite-magnetite; acetic acid-CO2) (\code{\link{buffer}}).
 
-  \item Multidimensional optimization (new in 0.9-3) - using an iterative gridded optimization, find a combination of chemical activities of basis species, temperature and/or pressure that maximize or minimize the value of a target statistic (\code{\link{findit}}).
+  \item Activity statistics (\bold{experimental}) - calculate summary statistics for equilibrium activities of species (\code{\link{revisit}}).
 
-  \item Mass transfer calculations (experimental) - calculate changes in solution composition and formation of secondary species as a function of incremental reaction of a mineral (or protein) (\code{\link{transfer}}).
+  \item Multidimensional optimization (new in 0.9-3) (\bold{experimental}) - using an iterative gridded optimization, find a combination of chemical activities of basis species, temperature and/or pressure that maximize or minimize the value of a target statistic (\code{\link{findit}}).
 
+  \item Mass transfer calculations (\bold{experimental}) - calculate changes in solution composition and formation of secondary species as a function of incremental reaction of a mineral (or protein) (\code{\link{transfer}}).
+
 }
 
   Here are some tips for new users:
@@ -59,9 +71,10 @@
     \item Install the package from CRAN using \code{\link{install.packages}} or its GUI menu equivalent. 
     \item To begin working with the package after installation, type \code{\link{library}(CHNOSZ)} at the command line (or select the name of the package from the GUI menu).
     \item Running the examples shown in the various help topics is a great way to become more familiar with the usage of the functions. From \code{\link{help.start}}, select \sQuote{Packages} then \sQuote{CHNOSZ} and then select a function of interest. Individual examples can be run by pasting the example block directly into the R console.
-    \item Type the command \code{\link{examples}()} to run all of the examples provided in CHNOSZ. This takes about five to ten minutes depending on your system. If things go as expected, the entire set will run without any warnings or errors.
-    \item Some of the examples require internet or file access or user intervention, or are intentionally written to demonstrate conditions that lead to errors. This offensive code is hidden from \R's package checking mechanism using the \code{dontrun} tag. You can experiment with \code{dontrun} examples by pasting the code to the R console.
+    \item Type the command \code{\link{examples}()} to run all of the examples provided in CHNOSZ. This takes a few minutes depending on your system. If things go as expected, the entire set will run without any warnings or errors.
+    \item Some of the examples require internet or file access or user intervention, or are intentionally written to demonstrate conditions that lead to errors. This code is hidden from \R's package checking mechanism using the \code{dontrun} tag. You can experiment with \code{dontrun} examples by pasting the code to the R console.
     \item A couple of other things to note about the examples: 1) There are some \code{\link{stopifnot}} statements that represent expected outcomes of the calculations; if the expectation is not met, the \code{stopifnot} statement causes an error. These tests are useful for checking the code during package development cycles, but are usually not of critical importance for the set-up of the problem (though they do sometimes employ useful programming tricks). 2) Commands written with an enclosing pair of parentheses \code{(z <- "like this one")} are used to display the result of an assignment operation (\code{\link{<-}}), the value of which is needed later in the calculation. In interactive use, the outermost pair of enclosing parentheses is generally not needed.
+    \item Also try out \code{\link{demos}()} to run the demos (some of these are longer running examples that are not part of the main help pages).
     \item To learn how to update the thermodynamic database, look at its documentation in \code{\link{thermo}}.
   }
 
@@ -84,11 +97,11 @@
 }
 
 \section{Known Bugs}{
+  \code{\link{subcrt}} does not correctly identify the stable polymorph of some minerals at high temperature.
+
   The values generated by \code{\link{buffer}} may not be applied correctly by \code{\link{affinity}} in calculating the affinities of the formation reactions. (The values returned by \code{affinity(..., return.buffer=TRUE)} do appear to be correct in the examples).
 
-  \code{\link{subcrt}} does not correctly identify the stable polymorph of some minerals at high temperature.
-
-  \code{\link{diagram}} causes an error while plotting stability field boundaries if the x and y resolutions are not identical.
+  There is an unidentified inconsistency in \code{\link{transfer}} causing the reaction boundaries in one of the examples (\code{apc("closed")}) to be offset from the stability diagram. OTOH, \code{feldspar("closed")} appears to work correctly.
 }
 
 \examples{

Modified: pkg/CHNOSZ/man/EOSregress.Rd
===================================================================
--- pkg/CHNOSZ/man/EOSregress.Rd	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/man/EOSregress.Rd	2015-05-19 14:38:46 UTC (rev 87)
@@ -166,4 +166,4 @@
 # not consistent with the high-T heat capacities
 }
 
-\keyword{extra}
+\concept{Extra thermodynamic modeling}

Modified: pkg/CHNOSZ/man/IAPWS95.Rd
===================================================================
--- pkg/CHNOSZ/man/IAPWS95.Rd	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/man/IAPWS95.Rd	2015-05-19 14:38:46 UTC (rev 87)
@@ -67,4 +67,4 @@
 }
 
 
-\keyword{secondary}
+\concept{Secondary thermodynamic modeling}

Modified: pkg/CHNOSZ/man/affinity.Rd
===================================================================
--- pkg/CHNOSZ/man/affinity.Rd	2015-05-18 14:21:16 UTC (rev 86)
+++ pkg/CHNOSZ/man/affinity.Rd	2015-05-19 14:38:46 UTC (rev 87)
@@ -92,7 +92,50 @@
 # Standard molal Gibbs energies of reactions
 affinity(property="G")
 
-\donttest{## amino acid synthesis at low and high temperatures
+## affinities of metabolic reactions
+## after Amend and Shock, 2001, Fig. 7
+# use aq state for all basis species (including O2)
+basis(c("CO2", "H2", "NH3", "O2", "H2S", "H+"), "aq")
+# we're going to make H2O
+species("H2O")
+# a function to create the plots
+doplot <- function(T) {
+  res <- 20
+  # calculate affinity/2.303RT as a function of loga(H2) and loga(O2)
+  a <- affinity(H2=c(-10, 0, res), O2=c(-10, 0, res), T=T)
+  T.K <- convert(T, "K")                   # temperature in Kelvin
+  acal <- convert(a$values[[1]], "G", T.K) # affinity (cal/mol)
+  akJ <- convert(acal, "J")/1000           # affinity (kJ/mol)
+  # now contour the values
+  xyvals <- seq(-10, 0, length.out=res)
+  contour(x=xyvals, y=xyvals, z=t(akJ), levels=seq(-150, -250, -20),
+    labcex=1, xlab=axis.label("H2"), ylab=axis.label("O2"))
+  # show the temperature
+  legend("topleft", bg="white", cex=1,
+    legend=describe.property("T", T, digits=0, ret.val=TRUE) )
+}
+# plot layout with space for title at top
+layout(matrix(c(1, 1, 2, 3, 4, 5), ncol=2, byrow=TRUE), heights=c(1, 4, 4))
+par(mar=c(0, 0, 0, 0))
+plot.new()
+# we use subcrt() to generate a reaction for titling the plot
+rxnexpr <- describe.reaction(subcrt("H2O", 1)$reaction, states="all")
+# also in the title is the property with its units
+E.units("J")
+Gexpr <- axis.label("DGr", prefix="k")[[2]]
+text(0.5, 0.6, substitute(paste(G~~"for"~~r), list(G=Gexpr, r=rxnexpr)), cex=2)
+text(0.5, 0.2, "after Amend and Shock, 2001 Figure 7", cex=2)
+# now make the plots
+par(mar=c(3, 3, 0.5, 0.5), cex=1.3, mgp=c(2, 1, 0))
+sapply(c(25, 55, 100, 150), doplot)
+# affinity() can handle the three dimensions simultaneously
+print(affinity(H2=c(-10, 0, 3), O2=c(-10, 0, 3), T=c(25, 150, 4))$values)
+# this is so the plots in the next examples show up OK
+E.units("cal")
+layout(matrix(1))
+par(mar=c(5.1, 4.1, 4.1, 2.1))
+
+## amino acid synthesis at low and high temperatures
 ## after Amend and Shock, 1998
 # select the basis species and species of interest
 # and set their activities, first for the 18 degree C case
@@ -138,49 +181,6 @@
 E.units("cal")
 species(delete=TRUE)
 
-## affinities of metabolic reactions
-## after Amend and Shock, 2001, Fig. 7
-# use aq state for all basis species (including O2)
-basis(c("CO2", "H2", "NH3", "O2", "H2S", "H+"), "aq")
-# we're going to make H2O
-species("H2O")
-# a function to create the plots
-doplot <- function(T) {
-  res <- 20
-  # calculate affinity/2.303RT as a function of loga(H2) and loga(O2)
-  a <- affinity(H2=c(-10, 0, res), O2=c(-10, 0, res), T=T)
-  T.K <- convert(T, "K")                   # temperature in Kelvin
-  acal <- convert(a$values[[1]], "G", T.K) # affinity (cal/mol)
-  akJ <- convert(acal, "J")/1000           # affinity (kJ/mol)
-  # now contour the values
-  xyvals <- seq(-10, 0, length.out=res)
-  contour(x=xyvals, y=xyvals, z=t(akJ), levels=seq(-150, -250, -20),
-    labcex=1, xlab=axis.label("H2"), ylab=axis.label("O2"))
-  # show the temperature
-  legend("topleft", bg="white", cex=1,
-    legend=describe.property("T", T, digits=0, ret.val=TRUE) )
-}
-# plot layout with space for title at top
[TRUNCATED]

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


More information about the CHNOSZ-commits mailing list