---
title: "Hyperosmotic Stress"
output:
  html_vignette:
    mathjax: null
vignette: >
  %\VignetteIndexEntry{Hyperosmotic Stress}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
bibliography: cpdat.bib
csl: peerj.csl
---

```{r setup, include=FALSE}
library(canprot)
library(CHNOSZ)
library(knitr)
## use pngquant to reduce size of PNG images
knit_hooks$set(pngquant = hook_pngquant)
pngquant <- "--speed=1 --quality=0-25"
# in case pngquant isn't available (R-Forge?)
if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL 
```

This vignette shows compositional metrics and phylostrata for proteins that are differentially expressed in hyperosmotic compared to control conditions.
Abbreviations:

  * <i>Z</i><sub>C</sub> &ndash; carbon oxidation state; <i>n</i><sub>H<sub>2</sub>O</sub> &ndash; stoichiometric hydration state; <i>n</i><sub>O<sub>2</sub></sub> &ndash; stoichiometric oxidation state.
  * <i>n</i><sub>AA</sub> &ndash; protein length; PS &ndash; phylostrata.
  * <i>n</i><sub>down</sub> &ndash; number of down-expressed proteins; <i>n</i><sub>up</sub> &ndash; number of up-expressed proteins.

Stoichiometric values are calculated using basis species (rQEC method; Dick et al., 2020) or amino acid biosynthetic reactions.
References for gene ages: [Trigos et al. (2017)](https://doi.org/10.1073/pnas.1617743114) (TPPG17); [Liebeskind et al. (2016)](https://doi.org/10.1093/gbe/evw113) (LMM16).

```{r options, echo=FALSE}
options(width = 90)
```

<style type="text/css">
body {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
</style>

```{r datasets}
datasets <- pdat_osmotic()
```

```{r comptab, results="hide", message=FALSE, echo = FALSE}
pdat1 <- lapply_canprot(datasets, pdat_osmotic)
comptab1 <- lapply(pdat1, get_comptab)
pdat2 <- lapply(pdat1, pdat_recomp, "biosynth")
comptab2 <- lapply(pdat2, get_comptab, "nO2")
comptab3 <- lapply(pdat1, get_comptab, "nAA", "PS")
comptab4 <- lapply(pdat1, get_comptab, "nAA", "PS", PS_source = "LMM16")
```

Dashed contour lines in the plots outline the 50% credible region for highest probability density.
Triangle symbols indicate transcriptomic datasets; all others are protein expression.

```{r diffplot, fig.width=8, fig.height=8, fig.align = "center", echo = FALSE, pngquant = pngquant}
par(mfrow = c(2, 2), mar = c(4, 4, 2, 2), mgp = c(2.5, 1, 0))
pch <- ifelse(grepl("transcript", datasets), 2, 1)
diffplot(comptab1, pch = pch)
title(quote("rQEC"~italic(n)[H[2]*O]), font.main = 1)
diffplot(comptab2, c("nO2", "nH2O"), pch = pch)
title(quote("Biosynthetic"~italic(n)[H[2]*O]~"and"~italic(n)[O[2]]), font.main = 1)
diffplot(comptab3, c("nAA", "PS"), pch = pch)
title("Trigos et al. (2017) ages", font.main = 1)
diffplot(comptab4, c("nAA", "PS"), pch = pch)
title("Liebeskind et al. (2016) ages", font.main = 1)
```

In the table, values of &Delta;<i>Z</i><sub>C</sub>, &Delta;<i>n</i><sub>H<sub>2</sub>O</sub> and &Delta;<i>n</i><sub>O<sub>2</sub></sub> are multiplied by 1000, values of &Delta;PS are multiplied by 100, and negative values are shown in bold.

```{r xsummary, results="asis", echo = FALSE}
library(xtable)
out <- xsummary2(comptab1, comptab2, comptab3, comptab4)
# round values and include dataset tags
tags <- sapply(sapply(strsplit(datasets, "="), "[", -1), paste, collapse = ";")
out <- cbind(out[, 1:2], tags = tags, out[, 3:25])
out[, 6:26] <- round(out[, 6:26], 4)
write.csv(out, "hyperosmotic.csv", row.names = FALSE, quote = 2)
```

## Data Sources

__a__. __b__. __c__. VHG (300 g/L) vs control (20 g/L). The comparisons here use proteins with expression ratios < 0.9 or > 1.1 and with p-values < 0.05. Source: SI Table of @PW08.
__d__. 24 h at 16.7 mM vs 5.6 mM glucose. Source: extracted from Suppl. Table ST4 of @WCM+09; including the red- and blue-highlighted rows in the source table (those with ANOVA _p_-value < 0.01), and applying the authors' criterion that proteins be identified by 2 or more unique peptides in at least 4 of the 8 most intense LC-MS/MS runs.
__e__. 300 mOsm (control) or 400 mOsm (NaCl treatment). Source: Suppl. Table 1 of @OBBH11.
__f__. __g__. Mannitol-balanced 5.5 (control), 25 or 100 mM ᴅ-glucose media. Source: Table 1 of @CCC+12.
__h__. __i__. __j__. __k__. Temperature and NaCl treatment (control: 35 °C, _a_~w~ = 0.993). Source: Suppl. Tables S13–S16 of @KKG+12.
__l__. __m__. 5.5 (control), 25 or 100 mM ᴅ-glucose. Source: Table 1 of @CCCC13.
__n__. Gill proteome of Japanese eel (_Anguilla japonica_) adapted to seawater or freshwater. Source: Protein IDs from Suppl. Table 3 and gene names of human orthologs from Suppl. File 4 of @TSZ+13.
__o__. __p__. __q__. 30 min in YNB (2% glucose) vs YPKG (0.5% glucose) media. Source: extracted from Suppl. Files 3 and 5 of @GSC14, using the authors' criterion of _p_-value <0.05.
__r__. 280 (control), 380, or 480 mOsm (NaCl treatment) for 24 h. Source: Table 2 of @CLG+15.
__s__. __t__. __u__. __v__. Overnight treatment with a final concentration of 40/50 mM NaCl or 200 mM sucrose vs M2 minimal salts medium plus glucose (control). Source: Additional file Table S2 of @KLB+15.
__w__. __x__. 15 g/L vs 5 g/L (control) glucose at days 0, 3, 6, and 9. The comparisons here use all proteins reported to have expression patterns in Cluster 1 (up) or Cluster 5 (down), or only the proteins with high expression differences (ratio ≤-0.2 or ≥0.2) at all time points. Source: SI Table S4 of @LDB+15.
__y__. 4.21 osmol/kg vs 3.17 osmol/kg osmotic pressure (NaCl treatment). Source: Table 1 of @YDZ+15.
__z__. 0.1 M KCl (treatment) vs medium with no added KCl (control). Source: Suppl. Tables 2 and 3 of @RBP+16.

## References
