---
title: "Figure 4A: Yield"
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 to the bead-beating related samples
```{r BB_subset1}
V13_BB <- subset_samples(V13, Exp.beadbeating == "YES")
```

Extract the sample data to a dataframe instead and reorder the levels of the beadbeating column.
```{r BB_to_dataframes, warning=FALSE}
S_BB<- sample_data(V13_BB) %>% as.data.frame()
S_BB$Beadbeating <- factor(S_BB$Beadbeating, levels = c("20s4ms","20s6ms","80s4ms","40s6ms","80s6ms","160s6ms","400s6ms"))
```

## Figure 4A: Yield vs. bead beating intensity
```{r Fig2A, fig.align='center', fig.width=2.6, fig.height=2.4}
ggplot(S_BB, aes(x=Beadbeating, y=Concentration)) +
  geom_point(size = 1.5) +
  ylab("Concentration [ng/ul]") +
  ylim(0, 250) +
  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(hjust = 0.5, size = 8, color = "black"),
        axis.text.y = element_text(size = 8, color = "black"),
        axis.title.y = element_text(vjust = 1, size = 8),
        axis.title.x = element_blank(),
        panel.grid = element_blank(),
        panel.background = element_blank(),
        axis.line = element_line(color = "black"),
        title = element_text(size = 8),
        plot.margin = unit(c(0,0,0,0), "mm"),
        axis.ticks.length = unit(1, "mm"),
        axis.ticks = element_line(color = "black")
   ) 
```

## Save 
```{r save, eval=FALSE}
ggsave("plots/Fig4A.eps", width = 60, height = 40, units = "mm")
```