---
title: "Figure S6 V4 Bead beating"
author: "Mads Albertsen"
date: "`r format(Sys.time(), '%d-%m-%Y')`"
output: html_document
---

## Load packages
```{r Load_packages, message=FALSE, warning=FALSE, results='hide'}
library("ampvis")
```

## Load data
```{r load_data}
data(DNAext_1.0)
```

## subset
First subset the samples to just include the relevant samples.
```{r BB_phyloseq_simple, message=FALSE}
V4_BB <- subset_samples(V4, Exp.beadbeating == "YES") %>%
  transform_sample_counts(function(x) x / sum(x) * 100)
```

## Figure S6A: Percentage abundance comparison
```{r BB_heatmap_percent, fig.align='center', fig.width=3.2, fig.height=2.8}
amp_heatmap(data = V4_BB,
            group = "Beadbeating",
            tax.aggregate = "Phylum",
            tax.empty = "remove",
            tax.class = "p__Proteobacteria",
            order.x = c("20s4ms","20s6ms","80s4ms","40s6ms","80s6ms","160s6ms","400s6ms"),
            order.y = "400s6ms",            
            plot.colorscale = "log10",
            plot.breaks = c(2,5,10,20), 
            scale.seq = 100,
            tax.show = 11,
            plot.theme = "clean",
            plot.text.size = 2
            ) +
    scale_x_discrete(labels = c("20s\n4m/s","20s\n6m/s","80s\n4m/s","40s\n6m/s","80s\n6m/s","160s\n6m/s","400s\n6m/s")) +
    theme(axis.text.x = element_text(size =6, color = "black", hjust = 0.4, angle = 0))
```

```{r save_S6A, eval=FALSE}
ggsave("plots/S6A.eps", width = 80, height = 70, units = "mm")
```

## Figure S6B: Normalised and scaled by DNA yield
```{r BB_heatmap_normalised_scaled1, fig.align='center', fig.width=3.2, fig.height=2.8}
amp_heatmap(data = V4_BB,
            group = "Beadbeating",
            normalise = "40s6ms",
            scale = "Concentration",
            tax.aggregate = "Phylum",
            tax.empty = "remove",
            tax.class = "p__Proteobacteria",
            order.x = c("20s4ms","20s6ms","80s4ms","40s6ms","80s6ms","160s6ms","400s6ms"),

            order.y = rev(c("Betaproteobacteria","Bacteroidetes","Alphaproteobacteria","Firmicutes","Actinobacteria", "Chloroflexi", "Gammaproteobacteria","Deltaproteobacteria","Nitrospirae", "Chlorobi","Acidobacteria")),    
            plot.colorscale = "log2",
            plot.breaks = c(0.3,1.0,3.0),
            scale.seq = 100,
            tax.show = 11,
            plot.theme = "clean",
            plot.text.size = 2
            ) +
    scale_x_discrete(labels = c("20s\n4m/s","20s\n6m/s","80s\n4m/s","40s\n6m/s","80s\n6m/s","160s\n6m/s","400s\n6m/s")) +
    theme(axis.text.x = element_text(size =6, color = "black", hjust = 0.4, angle = 0))
```

```{r save_S6B, eval=FALSE}
ggsave("plots/S6B.eps", width = 80, height = 70, units = "mm")
```