Notes

This notebook shows how raw electrochemical data from a CH Instruments potentiostat was processed for data vizualization and downstream analysis.


Setup packages and plotting for the notebook:

# Load packages
library(tidyverse)
library(cowplot)
library(kableExtra)

# Code display options
knitr::opts_chunk$set(tidy.opts=list(width.cutoff=60),tidy=FALSE, echo = TRUE, message=FALSE, warning=FALSE, fig.align="center", fig.retina = 2)

# Load plotting tools
source("../../tools/plotting_tools.R")

#Modify the plot theme
theme_1 <- function () {
  theme_classic( ) %+replace%
    theme(
      strip.background = element_blank(),
      legend.background = element_blank(),
      axis.line = element_line(color = 'black'),
      axis.ticks = element_line(color = 'black'),
      axis.text = element_text(color = 'black')
    )
}


theme_set(theme_1())

Import

In the folder data/Electrochemistry/IDA/ there are the raw data output to text files from the CH Instruments potentiostat software. There are files from two different biofilms, each containing three technical replicates.

We will use a set of simple tools developed to quickly import these files into data frames with metadata that we can work with. Basically, we will specifify a directory, the structure of the file names and the structure of the underlying data, and a function will import the files (~180 files for this notebook). Please see the the echem_processing_tools in the folder code/tools/ for details.

# Load echem processing tools

source("../../tools/echem_processing_tools.R")

SWV data

First, let’s import all of the SWV files for the first ∆phz* biofilm.

# file names and paths
swv_file_paths_1 <-  dir(path='../../../data/Electrochemistry/IDA/dPHZ_biofilm_1/', pattern = "[SWV]+.+[txt]$", recursive = T, full.names = T)

swv_filenames_1 <- basename(swv_file_paths_1)

# data columns in each file
swv_data_cols <-  c('E','i1','i2')

# metadata in each file name
filename_cols = c('reactor','run','echem','rep')

# skip the header that contains detailed information from the potentiostat
swv_skip_rows=18

# Use the function `echem_import_to_df()` from the echem tools to import
swv_data_1 <- echem_import_to_df(filenames = swv_filenames_1, 
                                       file_paths = swv_file_paths_1, 
                                       data_cols = swv_data_cols, 
                                       skip_rows = swv_skip_rows,
                                       filename_cols = filename_cols,
                                       rep = T, PHZadded = F) %>% 
  mutate(rep=rep-1, exp = 1) 

# Change the rep (acquisition number) for the SWVs because the first SWV should be 0.
# This is used to match SWV and GC by number later on.
# We also add an experimental id of 1.

Let’s look at the data frame we have generated:

swv_data_1 %>% head() %>%  kable(digits = 10) %>% kable_styling() %>% scroll_box(height = '300px')
reactor run echem rep minutes E electrode current exp
soak 1 SWV 0 941.1833 0.099 i1 1.263e-07 1
soak 1 SWV 0 941.1833 0.098 i1 1.435e-07 1
soak 1 SWV 0 941.1833 0.097 i1 1.456e-07 1
soak 1 SWV 0 941.1833 0.096 i1 1.492e-07 1
soak 1 SWV 0 941.1833 0.095 i1 1.315e-07 1
soak 1 SWV 0 941.1833 0.094 i1 1.513e-07 1


We can now plot all of these data. This plot will show the data from the first biofilm as it equilibrated in the transfer reactor and the data are separated for each technical replicate.

ggplot(swv_data_1 %>% filter(electrode == 'i1' & reactor == 'transfer'), aes(x = E , y = current )) +
  geom_path(aes(group = rep, color = rep)) + facet_wrap(~run)

Now let’s read in the SWV data for the second biofilm.

swv_file_paths_2 <-  dir(path='../../../data/Electrochemistry/IDA/dPHZ_biofilm_2/', pattern = "[SWV]+.+[txt]$",recursive = T,full.names = T)

swv_filenames_2 <- basename(swv_file_paths_2)
  
swv_data_2 <- echem_import_to_df(filenames = swv_filenames_2, 
                                 file_paths = swv_file_paths_2, 
                                 data_cols = swv_data_cols, 
                                 skip_rows = swv_skip_rows,
                                 filename_cols = filename_cols, 
                                 rep = T, 
                                 PHZadded = F) %>% 
  mutate(rep=rep-1, exp = 2)

Here is the second dataset plotted:

ggplot(swv_data_2 %>% filter(electrode == 'i1' & reactor == 'transfer'), aes(x = E , y = current )) +
  geom_path(aes(group = rep, color = rep)) + facet_wrap(~run)

GC data

Now, we will repeat the import for the GC data.

gc_file_paths_1 <-  dir(path='../../../data/Electrochemistry/IDA/dPHZ_biofilm_1/', pattern = "[GC]+.+[txt]$",recursive = T,full.names = T)

gc_filenames_1 <- basename(gc_file_paths_1)

gc_data_cols <-  c('E','i1','i2','t')

filename_cols = c('reactor','run','echem','rep')

gc_skip_rows=21
  

gc_data_1 <- echem_import_to_df(filenames = gc_filenames_1, 
                                       file_paths = gc_file_paths_1, 
                                       data_cols = gc_data_cols, 
                                       skip_rows = gc_skip_rows,
                                       filename_cols = filename_cols,
                                       rep = T, PHZadded = F) %>% 
  mutate(exp = 1)

Here’s the GC data plotted from the first biofilm:

ggplot(gc_data_1 %>% filter(reactor == 'transfer')) + 
  geom_path(data=. %>% filter(electrode=='i1'), aes(x = E, y = current, color = rep, group = rep)) + 
  geom_path(data=. %>% filter(electrode=='i2'), aes(x = E, y = current, color = rep, group = rep)) +
  scale_x_reverse() + facet_wrap(~run)

And now for the second biofilm.

gc_file_paths_2 <-  dir(path='../../../data/Electrochemistry/IDA/dPHZ_biofilm_2/', pattern = "[GC]+.+[txt]$",recursive = T,full.names = T)

gc_filenames_2 <- basename(gc_file_paths_2)

gc_data_cols <-  c('E','i1','i2','t')

filename_cols = c('reactor','run','echem','rep')

gc_skip_rows=21
  

gc_data_2 <- echem_import_to_df(filenames = gc_filenames_2, 
                                       file_paths = gc_file_paths_2, 
                                       data_cols = gc_data_cols, 
                                       skip_rows = gc_skip_rows,
                                       filename_cols = filename_cols,
                                       rep = T, PHZadded = F) %>% 
  mutate(exp = 2)

Here’s the GC data plotted from the second biofilm:

ggplot(gc_data_2 %>% filter(reactor == 'transfer')) + 
  geom_path(data=. %>% filter(electrode=='i1'), aes(x = E, y = current, color = rep, group = rep)) + 
  geom_path(data=. %>% filter(electrode=='i2'), aes(x = E, y = current, color = rep, group = rep)) +
  scale_x_reverse() + facet_wrap(~run)

Signal quantification

Now that all of the files have been read into convenient data frames we can quantify the peak currents, which are the signals we will use for the analysis later on.

SWV

To do this we will use another function from the echem tools to find the min and max points within a specified potential window in each scan. Let’s take a look at the output:

# combine swv data sets
swv_data <- bind_rows(swv_data_1, swv_data_2) 

# ID columns for function below
unique_id_cols = c('reactor','run','echem','rep','rep','minutes','electrode', 'exp')

# Use `echem_signal()` from echem tools to find min/max points in each scan
swv_signals <- echem_signal(df = swv_data, 
                            unique_id_cols = unique_id_cols,
                            max_interval = c(-0.2,-0.4), 
                            min_interval = c(0.0,-0.4)) 

swv_signals %>% kable(digits = 10) %>% kable_styling() %>% scroll_box(height = '300px')
reactor run echem rep minutes E_from_maxs electrode current_from_maxs exp max_current E_from_mins current_from_mins min_current signal
soak 1 SWV 0 941.1833 -0.267 i1 3.5177e-06 1 3.5177e-06 -0.082 1.0070e-07 1.0070e-07 3.4170e-06
transfer 1 SWV 0 951.7500 -0.268 i1 3.7691e-06 1 3.7691e-06 -0.095 1.0010e-07 1.0010e-07 3.6690e-06
transfer 1 SWV 9 977.2833 -0.268 i1 2.6130e-07 1 2.6130e-07 -0.057 9.3500e-08 9.3500e-08 1.6780e-07
transfer 1 SWV 10 980.0667 -0.272 i1 2.5670e-07 1 2.5670e-07 -0.127 8.9300e-08 8.9300e-08 1.6740e-07
transfer 1 SWV 11 983.5167 -0.271 i1 2.3200e-07 1 2.3200e-07 -0.088 8.9700e-08 8.9700e-08 1.4230e-07
transfer 1 SWV 12 986.2167 -0.264 i1 2.3760e-07 1 2.3760e-07 -0.115 8.8600e-08 8.8600e-08 1.4910e-07
transfer 1 SWV 13 988.9667 -0.274 i1 2.2280e-07 1 2.2280e-07 -0.072 8.9800e-08 8.9800e-08 1.3290e-07
transfer 1 SWV 14 991.7833 -0.260 i1 2.1190e-07 1 2.1190e-07 -0.072 9.1300e-08 9.1300e-08 1.2060e-07
transfer 1 SWV 15 994.5667 -0.275 i1 2.1320e-07 1 2.1320e-07 -0.123 9.2600e-08 9.2600e-08 1.2060e-07
transfer 1 SWV 1 954.6667 -0.266 i1 1.2638e-06 1 1.2638e-06 -0.040 9.7700e-08 9.7700e-08 1.1660e-06
transfer 1 SWV 2 957.3500 -0.265 i1 8.4360e-07 1 8.4360e-07 -0.034 9.7800e-08 9.7800e-08 7.4570e-07
transfer 1 SWV 3 960.0833 -0.266 i1 6.2500e-07 1 6.2500e-07 -0.073 9.2200e-08 9.2200e-08 5.3280e-07
transfer 1 SWV 4 963.0167 -0.268 i1 4.7340e-07 1 4.7340e-07 -0.085 9.4500e-08 9.4500e-08 3.7890e-07
transfer 1 SWV 5 965.7500 -0.266 i1 4.0450e-07 1 4.0450e-07 -0.078 9.2500e-08 9.2500e-08 3.1200e-07
transfer 1 SWV 6 968.4500 -0.268 i1 3.5850e-07 1 3.5850e-07 -0.111 9.1900e-08 9.1900e-08 2.6670e-07
transfer 1 SWV 7 971.6667 -0.264 i1 3.0000e-07 1 3.0000e-07 -0.088 9.0500e-08 9.0500e-08 2.0950e-07
transfer 1 SWV 8 974.4000 -0.265 i1 2.8310e-07 1 2.8310e-07 -0.072 9.0400e-08 9.0400e-08 1.9270e-07
soak 2 SWV 0 1009.4000 -0.270 i1 3.5581e-06 1 3.5581e-06 -0.058 6.8800e-08 6.8800e-08 3.4892e-06
transfer 2 SWV 0 1017.4667 -0.270 i1 2.4957e-06 1 2.4957e-06 -0.087 9.1900e-08 9.1900e-08 2.4039e-06
transfer 2 SWV 9 1042.5833 -0.270 i1 2.1930e-07 1 2.1930e-07 -0.094 8.2300e-08 8.2300e-08 1.3700e-07
transfer 2 SWV 10 1045.3833 -0.280 i1 2.0490e-07 1 2.0490e-07 -0.121 8.5300e-08 8.5300e-08 1.1970e-07
transfer 2 SWV 11 1048.2333 -0.261 i1 1.9960e-07 1 1.9960e-07 -0.083 8.3900e-08 8.3900e-08 1.1570e-07
transfer 2 SWV 12 1050.9667 -0.263 i1 2.0580e-07 1 2.0580e-07 -0.104 8.5800e-08 8.5800e-08 1.1990e-07
transfer 2 SWV 13 1053.9333 -0.288 i1 2.0020e-07 1 2.0020e-07 -0.093 7.9200e-08 7.9200e-08 1.2100e-07
transfer 2 SWV 14 1056.6833 -0.284 i1 1.9220e-07 1 1.9220e-07 -0.144 8.7500e-08 8.7500e-08 1.0480e-07
transfer 2 SWV 15 1059.5000 -0.280 i1 1.9030e-07 1 1.9030e-07 -0.099 8.2800e-08 8.2800e-08 1.0740e-07
transfer 2 SWV 1 1020.4000 -0.275 i1 8.1170e-07 1 8.1170e-07 -0.075 8.8600e-08 8.8600e-08 7.2310e-07
transfer 2 SWV 2 1023.1333 -0.265 i1 5.3740e-07 1 5.3740e-07 -0.063 8.2500e-08 8.2500e-08 4.5490e-07
transfer 2 SWV 3 1025.8667 -0.271 i1 4.1680e-07 1 4.1680e-07 -0.064 7.7000e-08 7.7000e-08 3.3980e-07
transfer 2 SWV 4 1028.5500 -0.271 i1 3.4370e-07 1 3.4370e-07 -0.143 8.5800e-08 8.5800e-08 2.5790e-07
transfer 2 SWV 5 1031.2667 -0.271 i1 2.8750e-07 1 2.8750e-07 -0.129 8.6000e-08 8.6000e-08 2.0160e-07
transfer 2 SWV 6 1034.4000 -0.273 i1 2.6500e-07 1 2.6500e-07 -0.090 7.9400e-08 7.9400e-08 1.8560e-07
transfer 2 SWV 7 1037.1000 -0.272 i1 2.4030e-07 1 2.4030e-07 -0.151 8.8400e-08 8.8400e-08 1.5190e-07
transfer 2 SWV 8 1039.8333 -0.268 i1 2.2170e-07 1 2.2170e-07 -0.080 8.3700e-08 8.3700e-08 1.3800e-07
soak 3 SWV 0 1102.1500 -0.268 i1 3.8687e-06 1 3.8687e-06 -0.049 1.0430e-07 1.0430e-07 3.7644e-06
transfer 3 SWV 0 1108.9833 -0.270 i1 2.7714e-06 1 2.7714e-06 -0.075 9.7100e-08 9.7100e-08 2.6742e-06
transfer 3 SWV 9 1134.0833 -0.268 i1 2.7990e-07 1 2.7990e-07 -0.092 9.3300e-08 9.3300e-08 1.8660e-07
transfer 3 SWV 10 1136.8167 -0.265 i1 2.6430e-07 1 2.6430e-07 -0.080 9.3000e-08 9.3000e-08 1.7130e-07
transfer 3 SWV 11 1139.6333 -0.264 i1 2.5480e-07 1 2.5480e-07 -0.117 9.3500e-08 9.3500e-08 1.6130e-07
transfer 3 SWV 12 1142.4000 -0.278 i1 2.4080e-07 1 2.4080e-07 -0.071 8.8800e-08 8.8800e-08 1.5200e-07
transfer 3 SWV 13 1145.1667 -0.278 i1 2.3190e-07 1 2.3190e-07 -0.097 8.6900e-08 8.6900e-08 1.4500e-07
transfer 3 SWV 14 1148.0000 -0.265 i1 2.2370e-07 1 2.2370e-07 -0.084 9.1900e-08 9.1900e-08 1.3180e-07
transfer 3 SWV 15 1150.7667 -0.268 i1 2.2250e-07 1 2.2250e-07 -0.092 9.2200e-08 9.2200e-08 1.3030e-07
transfer 3 SWV 1 1111.8833 -0.272 i1 1.1313e-06 1 1.1313e-06 -0.058 9.8700e-08 9.8700e-08 1.0326e-06
transfer 3 SWV 2 1114.5667 -0.269 i1 7.7210e-07 1 7.7210e-07 -0.112 9.2400e-08 9.2400e-08 6.7970e-07
transfer 3 SWV 3 1117.2833 -0.270 i1 6.0710e-07 1 6.0710e-07 -0.056 9.4300e-08 9.4300e-08 5.1280e-07
transfer 3 SWV 4 1120.0500 -0.270 i1 4.9510e-07 1 4.9510e-07 -0.092 9.3200e-08 9.3200e-08 4.0190e-07
transfer 3 SWV 5 1122.8667 -0.274 i1 4.1170e-07 1 4.1170e-07 -0.088 9.6200e-08 9.6200e-08 3.1550e-07
transfer 3 SWV 6 1125.8333 -0.269 i1 3.5500e-07 1 3.5500e-07 -0.107 9.3100e-08 9.3100e-08 2.6190e-07
transfer 3 SWV 7 1128.6333 -0.275 i1 3.1730e-07 1 3.1730e-07 -0.118 9.6700e-08 9.6700e-08 2.2060e-07
transfer 3 SWV 8 1131.3833 -0.275 i1 2.9510e-07 1 2.9510e-07 -0.135 9.2700e-08 9.2700e-08 2.0240e-07
control transfer 0 NA 920.3333 -0.399 i1 1.6330e-07 1 1.6330e-07 -0.096 6.9200e-08 6.9200e-08 9.4100e-08
soak 1 SWV 0 941.1833 -0.270 i2 3.3946e-06 1 3.3946e-06 -0.068 5.6000e-08 5.6000e-08 3.3386e-06
transfer 1 SWV 0 951.7500 -0.267 i2 3.5699e-06 1 3.5699e-06 -0.005 6.9500e-08 6.9500e-08 3.5004e-06
transfer 1 SWV 9 977.2833 -0.355 i2 2.0089e-06 1 2.0089e-06 -0.035 7.0500e-08 7.0500e-08 1.9384e-06
transfer 1 SWV 10 980.0667 -0.354 i2 2.0260e-06 1 2.0260e-06 -0.008 6.7800e-08 6.7800e-08 1.9582e-06
transfer 1 SWV 11 983.5167 -0.351 i2 2.2120e-06 1 2.2120e-06 -0.028 6.9200e-08 6.9200e-08 2.1428e-06
transfer 1 SWV 12 986.2167 -0.345 i2 2.0547e-06 1 2.0547e-06 -0.004 5.9400e-08 5.9400e-08 1.9954e-06
transfer 1 SWV 13 988.9667 -0.347 i2 2.0217e-06 1 2.0217e-06 -0.027 6.4100e-08 6.4100e-08 1.9576e-06
transfer 1 SWV 14 991.7833 -0.346 i2 1.9977e-06 1 1.9977e-06 -0.024 5.7800e-08 5.7800e-08 1.9399e-06
transfer 1 SWV 15 994.5667 -0.352 i2 1.9885e-06 1 1.9885e-06 -0.028 6.6000e-08 6.6000e-08 1.9225e-06
transfer 1 SWV 1 954.6667 -0.272 i2 1.3404e-06 1 1.3404e-06 -0.059 7.8300e-08 7.8300e-08 1.2621e-06
transfer 1 SWV 2 957.3500 -0.366 i2 1.7225e-06 1 1.7225e-06 -0.018 8.7200e-08 8.7200e-08 1.6353e-06
transfer 1 SWV 3 960.0833 -0.358 i2 1.9747e-06 1 1.9747e-06 -0.023 7.8100e-08 7.8100e-08 1.8966e-06
transfer 1 SWV 4 963.0167 -0.362 i2 1.8410e-06 1 1.8410e-06 -0.028 8.3400e-08 8.3400e-08 1.7576e-06
transfer 1 SWV 5 965.7500 -0.348 i2 2.0658e-06 1 2.0658e-06 -0.021 7.0000e-08 7.0000e-08 1.9958e-06
transfer 1 SWV 6 968.4500 -0.353 i2 2.0898e-06 1 2.0898e-06 -0.023 7.3500e-08 7.3500e-08 2.0163e-06
transfer 1 SWV 7 971.6667 -0.354 i2 1.7706e-06 1 1.7706e-06 -0.027 7.6100e-08 7.6100e-08 1.6945e-06
transfer 1 SWV 8 974.4000 -0.343 i2 2.0422e-06 1 2.0422e-06 -0.003 6.9700e-08 6.9700e-08 1.9725e-06
soak 2 SWV 0 1009.4000 -0.265 i2 2.8249e-06 1 2.8249e-06 -0.088 8.0400e-08 8.0400e-08 2.7445e-06
transfer 2 SWV 0 1017.4667 -0.273 i2 1.4632e-06 1 1.4632e-06 -0.023 8.1400e-08 8.1400e-08 1.3818e-06
transfer 2 SWV 9 1042.5833 -0.354 i2 2.0766e-06 1 2.0766e-06 -0.008 7.5800e-08 7.5800e-08 2.0008e-06
transfer 2 SWV 10 1045.3833 -0.350 i2 2.0518e-06 1 2.0518e-06 -0.002 7.1800e-08 7.1800e-08 1.9800e-06
transfer 2 SWV 11 1048.2333 -0.352 i2 1.9909e-06 1 1.9909e-06 -0.016 7.3300e-08 7.3300e-08 1.9176e-06
transfer 2 SWV 12 1050.9667 -0.357 i2 1.9685e-06 1 1.9685e-06 -0.016 7.5300e-08 7.5300e-08 1.8932e-06
transfer 2 SWV 13 1053.9333 -0.355 i2 1.9090e-06 1 1.9090e-06 -0.062 8.0000e-08 8.0000e-08 1.8290e-06
transfer 2 SWV 14 1056.6833 -0.359 i2 1.9162e-06 1 1.9162e-06 -0.001 7.1700e-08 7.1700e-08 1.8445e-06
transfer 2 SWV 15 1059.5000 -0.352 i2 1.8706e-06 1 1.8706e-06 -0.003 7.4500e-08 7.4500e-08 1.7961e-06
transfer 2 SWV 1 1020.4000 -0.364 i2 1.9663e-06 1 1.9663e-06 -0.015 8.0800e-08 8.0800e-08 1.8855e-06
transfer 2 SWV 2 1023.1333 -0.359 i2 2.2607e-06 1 2.2607e-06 -0.011 8.8200e-08 8.8200e-08 2.1725e-06
transfer 2 SWV 3 1025.8667 -0.348 i2 2.3238e-06 1 2.3238e-06 -0.016 8.8700e-08 8.8700e-08 2.2351e-06
transfer 2 SWV 4 1028.5500 -0.348 i2 2.2620e-06 1 2.2620e-06 -0.026 9.3600e-08 9.3600e-08 2.1684e-06
transfer 2 SWV 5 1031.2667 -0.350 i2 2.2219e-06 1 2.2219e-06 -0.007 8.4400e-08 8.4400e-08 2.1375e-06
transfer 2 SWV 6 1034.4000 -0.355 i2 2.2272e-06 1 2.2272e-06 -0.002 7.8800e-08 7.8800e-08 2.1485e-06
transfer 2 SWV 7 1037.1000 -0.349 i2 2.1625e-06 1 2.1625e-06 -0.008 8.2400e-08 8.2400e-08 2.0801e-06
transfer 2 SWV 8 1039.8333 -0.350 i2 2.1140e-06 1 2.1140e-06 -0.011 6.8400e-08 6.8400e-08 2.0457e-06
soak 3 SWV 0 1102.1500 -0.273 i2 3.6313e-06 1 3.6313e-06 -0.059 8.3300e-08 8.3300e-08 3.5479e-06
transfer 3 SWV 0 1108.9833 -0.273 i2 2.3450e-06 1 2.3450e-06 -0.032 8.2100e-08 8.2100e-08 2.2628e-06
transfer 3 SWV 9 1134.0833 -0.361 i2 2.4196e-06 1 2.4196e-06 -0.028 8.4800e-08 8.4800e-08 2.3349e-06
transfer 3 SWV 10 1136.8167 -0.355 i2 2.4342e-06 1 2.4342e-06 -0.008 6.9900e-08 6.9900e-08 2.3643e-06
transfer 3 SWV 11 1139.6333 -0.361 i2 2.3941e-06 1 2.3941e-06 -0.053 7.1200e-08 7.1200e-08 2.3229e-06
transfer 3 SWV 12 1142.4000 -0.355 i2 2.3792e-06 1 2.3792e-06 -0.015 6.8000e-08 6.8000e-08 2.3112e-06
transfer 3 SWV 13 1145.1667 -0.362 i2 2.3192e-06 1 2.3192e-06 -0.016 8.0500e-08 8.0500e-08 2.2387e-06
transfer 3 SWV 14 1148.0000 -0.349 i2 2.3054e-06 1 2.3054e-06 -0.001 7.5900e-08 7.5900e-08 2.2295e-06
transfer 3 SWV 15 1150.7667 -0.350 i2 2.2571e-06 1 2.2571e-06 -0.013 7.3800e-08 7.3800e-08 2.1833e-06
transfer 3 SWV 1 1111.8833 -0.378 i2 2.1250e-06 1 2.1250e-06 -0.018 9.6500e-08 9.6500e-08 2.0285e-06
transfer 3 SWV 2 1114.5667 -0.370 i2 2.7684e-06 1 2.7684e-06 -0.029 1.0520e-07 1.0520e-07 2.6633e-06
transfer 3 SWV 3 1117.2833 -0.352 i2 2.6156e-06 1 2.6156e-06 -0.059 9.0400e-08 9.0400e-08 2.5251e-06
transfer 3 SWV 4 1120.0500 -0.359 i2 2.5171e-06 1 2.5171e-06 -0.021 7.8200e-08 7.8200e-08 2.4389e-06
transfer 3 SWV 5 1122.8667 -0.359 i2 2.4083e-06 1 2.4083e-06 -0.010 8.9200e-08 8.9200e-08 2.3191e-06
transfer 3 SWV 6 1125.8333 -0.362 i2 2.3480e-06 1 2.3480e-06 -0.002 7.4600e-08 7.4600e-08 2.2734e-06
transfer 3 SWV 7 1128.6333 -0.356 i2 2.4414e-06 1 2.4414e-06 -0.035 9.2700e-08 9.2700e-08 2.3487e-06
transfer 3 SWV 8 1131.3833 -0.350 i2 2.4390e-06 1 2.4390e-06 -0.044 8.9600e-08 8.9600e-08 2.3494e-06
control transfer 0 NA 920.3333 -0.396 i2 1.7150e-07 1 1.7150e-07 -0.180 3.9200e-08 3.9200e-08 1.3230e-07
soak 1 SWV 0 919.7833 -0.222 i1 7.7034e-06 2 7.7034e-06 -0.009 1.0750e-06 1.0750e-06 6.6284e-06
transfer 1 SWV 0 922.9167 -0.219 i1 4.0279e-06 2 4.0279e-06 -0.011 1.0984e-06 1.0984e-06 2.9295e-06
transfer 1 SWV 9 948.4833 -0.219 i1 1.4279e-06 2 1.4279e-06 -0.036 1.0820e-06 1.0820e-06 3.4600e-07
transfer 1 SWV 10 951.2000 -0.216 i1 1.3988e-06 2 1.3988e-06 -0.058 1.0856e-06 1.0856e-06 3.1320e-07
transfer 1 SWV 11 953.8833 -0.212 i1 1.3803e-06 2 1.3803e-06 -0.044 1.0866e-06 1.0866e-06 2.9370e-07
transfer 1 SWV 12 956.6000 -0.218 i1 1.3744e-06 2 1.3744e-06 -0.062 1.0852e-06 1.0852e-06 2.8920e-07
transfer 1 SWV 13 959.3333 -0.222 i1 1.3461e-06 2 1.3461e-06 -0.059 1.0871e-06 1.0871e-06 2.5900e-07
transfer 1 SWV 14 962.0833 -0.214 i1 1.3448e-06 2 1.3448e-06 -0.056 1.0879e-06 1.0879e-06 2.5690e-07
transfer 1 SWV 15 964.8333 -0.214 i1 1.3270e-06 2 1.3270e-06 -0.047 1.0835e-06 1.0835e-06 2.4350e-07
transfer 1 SWV 1 925.8000 -0.219 i1 2.1303e-06 2 2.1303e-06 -0.035 1.0948e-06 1.0948e-06 1.0355e-06
transfer 1 SWV 2 928.6167 -0.219 i1 1.8181e-06 2 1.8181e-06 -0.051 1.0878e-06 1.0878e-06 7.3020e-07
transfer 1 SWV 3 931.4500 -0.218 i1 1.7092e-06 2 1.7092e-06 -0.047 1.0850e-06 1.0850e-06 6.2420e-07
transfer 1 SWV 4 934.5167 -0.216 i1 1.6060e-06 2 1.6060e-06 -0.028 1.0865e-06 1.0865e-06 5.1960e-07
transfer 1 SWV 5 937.6333 -0.214 i1 1.5858e-06 2 1.5858e-06 -0.031 1.0866e-06 1.0866e-06 4.9920e-07
transfer 1 SWV 6 940.3333 -0.217 i1 1.4680e-06 2 1.4680e-06 -0.038 1.0838e-06 1.0838e-06 3.8420e-07
transfer 1 SWV 7 943.0667 -0.218 i1 1.4932e-06 2 1.4932e-06 -0.050 1.0853e-06 1.0853e-06 4.0790e-07
transfer 1 SWV 8 945.7833 -0.221 i1 1.4511e-06 2 1.4511e-06 -0.043 1.0850e-06 1.0850e-06 3.6600e-07
soak 2 SWV 0 987.4833 -0.223 i1 7.7170e-06 2 7.7170e-06 -0.015 1.0737e-06 1.0737e-06 6.6433e-06
transfer 2 SWV 0 991.1667 -0.222 i1 6.7434e-06 2 6.7434e-06 -0.036 1.1358e-06 1.1358e-06 5.6076e-06
transfer 2 SWV 9 1016.6167 -0.218 i1 1.4338e-06 2 1.4338e-06 -0.044 1.1391e-06 1.1391e-06 2.9470e-07
transfer 2 SWV 10 1019.7167 -0.218 i1 1.4017e-06 2 1.4017e-06 -0.067 1.1250e-06 1.1250e-06 2.7670e-07
transfer 2 SWV 11 1022.4667 -0.220 i1 1.3688e-06 2 1.3688e-06 -0.064 1.1263e-06 1.1263e-06 2.4260e-07
transfer 2 SWV 12 1025.2167 -0.216 i1 1.3633e-06 2 1.3633e-06 -0.059 1.1241e-06 1.1241e-06 2.3920e-07
transfer 2 SWV 13 1027.9667 -0.214 i1 1.3571e-06 2 1.3571e-06 -0.051 1.1280e-06 1.1280e-06 2.2920e-07
transfer 2 SWV 14 1030.5833 -0.218 i1 1.3527e-06 2 1.3527e-06 -0.057 1.1222e-06 1.1222e-06 2.3050e-07
transfer 2 SWV 15 1033.3667 -0.220 i1 1.3292e-06 2 1.3292e-06 -0.057 1.1258e-06 1.1258e-06 2.0340e-07
transfer 2 SWV 1 994.1167 -0.220 i1 2.7772e-06 2 2.7772e-06 -0.047 1.2342e-06 1.2342e-06 1.5430e-06
transfer 2 SWV 2 997.3667 -0.221 i1 2.2016e-06 2 2.2016e-06 -0.034 1.2130e-06 1.2130e-06 9.8870e-07
transfer 2 SWV 3 1000.2667 -0.221 i1 1.7946e-06 2 1.7946e-06 -0.033 1.2112e-06 1.2112e-06 5.8340e-07
transfer 2 SWV 4 1002.9667 -0.220 i1 1.6608e-06 2 1.6608e-06 -0.029 1.1791e-06 1.1791e-06 4.8160e-07
transfer 2 SWV 5 1005.7167 -0.223 i1 1.5741e-06 2 1.5741e-06 -0.046 1.1677e-06 1.1677e-06 4.0640e-07
transfer 2 SWV 6 1008.4167 -0.214 i1 1.5215e-06 2 1.5215e-06 -0.041 1.1644e-06 1.1644e-06 3.5720e-07
transfer 2 SWV 7 1011.2167 -0.222 i1 1.4713e-06 2 1.4713e-06 -0.046 1.1506e-06 1.1506e-06 3.2070e-07
transfer 2 SWV 8 1013.9167 -0.217 i1 1.4300e-06 2 1.4300e-06 -0.049 1.1460e-06 1.1460e-06 2.8400e-07
soak 3 SWV 0 1131.2167 -0.269 i1 6.8982e-06 2 6.8982e-06 -0.011 1.8591e-06 1.8591e-06 5.0391e-06
transfer 3 SWV 0 1134.1500 -0.265 i1 4.9629e-06 2 4.9629e-06 -0.397 1.7208e-06 1.7208e-06 3.2420e-06
transfer 3 SWV 9 1159.4333 -0.237 i1 1.8881e-06 2 1.8881e-06 -0.398 1.3868e-06 1.3868e-06 5.0130e-07
transfer 3 SWV 10 1162.1833 -0.245 i1 1.8611e-06 2 1.8611e-06 -0.399 1.3701e-06 1.3701e-06 4.9100e-07
transfer 3 SWV 11 1164.9000 -0.210 i1 1.8206e-06 2 1.8206e-06 -0.390 1.3670e-06 1.3670e-06 4.5350e-07
transfer 3 SWV 12 1167.6667 -0.244 i1 1.7996e-06 2 1.7996e-06 -0.400 1.3463e-06 1.3463e-06 4.5330e-07
transfer 3 SWV 13 1170.4667 -0.206 i1 1.7712e-06 2 1.7712e-06 -0.399 1.3370e-06 1.3370e-06 4.3420e-07
transfer 3 SWV 14 1173.2167 -0.226 i1 1.7533e-06 2 1.7533e-06 -0.385 1.3379e-06 1.3379e-06 4.1540e-07
transfer 3 SWV 15 1176.0167 -0.211 i1 1.7311e-06 2 1.7311e-06 -0.396 1.3185e-06 1.3185e-06 4.1250e-07
transfer 3 SWV 1 1137.1000 -0.266 i1 2.9531e-06 2 2.9531e-06 -0.398 1.5899e-06 1.5899e-06 1.3632e-06
transfer 3 SWV 2 1139.9167 -0.257 i1 2.6293e-06 2 2.6293e-06 -0.399 1.5429e-06 1.5429e-06 1.0864e-06
transfer 3 SWV 3 1142.6333 -0.258 i1 2.3587e-06 2 2.3587e-06 -0.398 1.5011e-06 1.5011e-06 8.5760e-07
transfer 3 SWV 4 1145.3333 -0.256 i1 2.2311e-06 2 2.2311e-06 -0.396 1.4712e-06 1.4712e-06 7.5990e-07
transfer 3 SWV 5 1148.0500 -0.249 i1 2.1086e-06 2 2.1086e-06 -0.399 1.4430e-06 1.4430e-06 6.6560e-07
transfer 3 SWV 6 1151.1167 -0.243 i1 2.0436e-06 2 2.0436e-06 -0.399 1.4110e-06 1.4110e-06 6.3260e-07
transfer 3 SWV 7 1153.8500 -0.239 i1 1.9839e-06 2 1.9839e-06 -0.398 1.4177e-06 1.4177e-06 5.6620e-07
transfer 3 SWV 8 1156.6833 -0.233 i1 1.9280e-06 2 1.9280e-06 -0.389 1.4003e-06 1.4003e-06 5.2770e-07
control transfer 0 NA 890.3500 -0.400 i1 1.2746e-06 2 1.2746e-06 -0.072 1.0262e-06 1.0262e-06 2.4840e-07
soak 1 SWV 0 919.7833 -0.222 i2 6.8384e-06 2 6.8384e-06 -0.009 6.5530e-07 6.5530e-07 6.1830e-06
transfer 1 SWV 0 922.9167 -0.216 i2 3.3522e-06 2 3.3522e-06 -0.003 6.6470e-07 6.6470e-07 2.6875e-06
transfer 1 SWV 9 948.4833 -0.319 i2 3.3897e-06 2 3.3897e-06 -0.001 6.6360e-07 6.6360e-07 2.7261e-06
transfer 1 SWV 10 951.2000 -0.316 i2 3.3823e-06 2 3.3823e-06 -0.002 6.5840e-07 6.5840e-07 2.7239e-06
transfer 1 SWV 11 953.8833 -0.318 i2 3.3901e-06 2 3.3901e-06 0.000 6.5710e-07 6.5710e-07 2.7330e-06
transfer 1 SWV 12 956.6000 -0.314 i2 3.3285e-06 2 3.3285e-06 -0.002 6.6040e-07 6.6040e-07 2.6681e-06
transfer 1 SWV 13 959.3333 -0.314 i2 3.3073e-06 2 3.3073e-06 0.000 6.5440e-07 6.5440e-07 2.6529e-06
transfer 1 SWV 14 962.0833 -0.316 i2 3.2964e-06 2 3.2964e-06 -0.002 6.5040e-07 6.5040e-07 2.6459e-06
transfer 1 SWV 15 964.8333 -0.316 i2 3.3063e-06 2 3.3063e-06 -0.001 6.5870e-07 6.5870e-07 2.6476e-06
transfer 1 SWV 1 925.8000 -0.324 i2 2.2237e-06 2 2.2237e-06 -0.002 6.7600e-07 6.7600e-07 1.5477e-06
transfer 1 SWV 2 928.6167 -0.324 i2 3.0412e-06 2 3.0412e-06 -0.002 6.8280e-07 6.8280e-07 2.3584e-06
transfer 1 SWV 3 931.4500 -0.331 i2 3.0777e-06 2 3.0777e-06 -0.003 6.9130e-07 6.9130e-07 2.3864e-06
transfer 1 SWV 4 934.5167 -0.322 i2 3.3478e-06 2 3.3478e-06 -0.004 6.7740e-07 6.7740e-07 2.6704e-06
transfer 1 SWV 5 937.6333 -0.319 i2 3.5109e-06 2 3.5109e-06 0.000 6.7400e-07 6.7400e-07 2.8370e-06
transfer 1 SWV 6 940.3333 -0.318 i2 3.5161e-06 2 3.5161e-06 0.000 6.6840e-07 6.6840e-07 2.8477e-06
transfer 1 SWV 7 943.0667 -0.319 i2 3.3623e-06 2 3.3623e-06 -0.001 6.6870e-07 6.6870e-07 2.6935e-06
transfer 1 SWV 8 945.7833 -0.321 i2 3.4088e-06 2 3.4088e-06 -0.009 6.6370e-07 6.6370e-07 2.7450e-06
soak 2 SWV 0 987.4833 -0.223 i2 6.2230e-06 2 6.2230e-06 -0.015 6.6650e-07 6.6650e-07 5.5565e-06
transfer 2 SWV 0 991.1667 -0.218 i2 4.8109e-06 2 4.8109e-06 -0.012 6.6020e-07 6.6020e-07 4.1507e-06
transfer 2 SWV 9 1016.6167 -0.319 i2 2.9128e-06 2 2.9128e-06 -0.006 6.5870e-07 6.5870e-07 2.2541e-06
transfer 2 SWV 10 1019.7167 -0.322 i2 2.9085e-06 2 2.9085e-06 -0.002 6.6580e-07 6.6580e-07 2.2427e-06
transfer 2 SWV 11 1022.4667 -0.317 i2 2.8586e-06 2 2.8586e-06 -0.009 6.6060e-07 6.6060e-07 2.1980e-06
transfer 2 SWV 12 1025.2167 -0.317 i2 2.7375e-06 2 2.7375e-06 -0.003 6.6440e-07 6.6440e-07 2.0731e-06
transfer 2 SWV 13 1027.9667 -0.318 i2 2.7128e-06 2 2.7128e-06 -0.011 6.5630e-07 6.5630e-07 2.0565e-06
transfer 2 SWV 14 1030.5833 -0.315 i2 2.6909e-06 2 2.6909e-06 -0.012 6.6280e-07 6.6280e-07 2.0281e-06
transfer 2 SWV 15 1033.3667 -0.316 i2 2.6739e-06 2 2.6739e-06 -0.003 6.5260e-07 6.5260e-07 2.0214e-06
transfer 2 SWV 1 994.1167 -0.315 i2 2.8788e-06 2 2.8788e-06 -0.003 6.6730e-07 6.6730e-07 2.2115e-06
transfer 2 SWV 2 997.3667 -0.322 i2 3.1477e-06 2 3.1477e-06 -0.003 6.7310e-07 6.7310e-07 2.4746e-06
transfer 2 SWV 3 1000.2667 -0.320 i2 2.9949e-06 2 2.9949e-06 -0.004 6.6030e-07 6.6030e-07 2.3347e-06
transfer 2 SWV 4 1002.9667 -0.322 i2 2.9523e-06 2 2.9523e-06 -0.029 6.6940e-07 6.6940e-07 2.2829e-06
transfer 2 SWV 5 1005.7167 -0.319 i2 2.9082e-06 2 2.9082e-06 -0.011 6.6900e-07 6.6900e-07 2.2393e-06
transfer 2 SWV 6 1008.4167 -0.320 i2 2.9235e-06 2 2.9235e-06 -0.002 6.5820e-07 6.5820e-07 2.2654e-06
transfer 2 SWV 7 1011.2167 -0.318 i2 2.9802e-06 2 2.9802e-06 -0.005 6.6600e-07 6.6600e-07 2.3142e-06
transfer 2 SWV 8 1013.9167 -0.318 i2 2.9239e-06 2 2.9239e-06 -0.005 6.5960e-07 6.5960e-07 2.2643e-06
soak 3 SWV 0 1131.2167 -0.273 i2 7.5976e-06 2 7.5976e-06 -0.007 1.0987e-06 1.0987e-06 6.4989e-06
transfer 3 SWV 0 1134.1500 -0.270 i2 5.4946e-06 2 5.4946e-06 -0.007 1.0555e-06 1.0555e-06 4.4391e-06
transfer 3 SWV 9 1159.4333 -0.348 i2 2.9933e-06 2 2.9933e-06 -0.038 9.1610e-07 9.1610e-07 2.0773e-06
transfer 3 SWV 10 1162.1833 -0.348 i2 2.9912e-06 2 2.9912e-06 -0.046 9.0220e-07 9.0220e-07 2.0890e-06
transfer 3 SWV 11 1164.9000 -0.348 i2 2.9073e-06 2 2.9073e-06 -0.031 9.0600e-07 9.0600e-07 2.0013e-06
transfer 3 SWV 12 1167.6667 -0.359 i2 2.8769e-06 2 2.8769e-06 -0.070 9.1440e-07 9.1440e-07 1.9625e-06
transfer 3 SWV 13 1170.4667 -0.343 i2 2.8264e-06 2 2.8264e-06 -0.042 8.8580e-07 8.8580e-07 1.9406e-06
transfer 3 SWV 14 1173.2167 -0.347 i2 2.7728e-06 2 2.7728e-06 -0.062 8.9810e-07 8.9810e-07 1.8748e-06
transfer 3 SWV 15 1176.0167 -0.334 i2 2.6854e-06 2 2.6854e-06 -0.060 9.1930e-07 9.1930e-07 1.7661e-06
transfer 3 SWV 1 1137.1000 -0.278 i2 3.7941e-06 2 3.7941e-06 -0.020 1.0836e-06 1.0836e-06 2.7105e-06
transfer 3 SWV 2 1139.9167 -0.274 i2 3.8284e-06 2 3.8284e-06 -0.021 9.7720e-07 9.7720e-07 2.8511e-06
transfer 3 SWV 3 1142.6333 -0.328 i2 3.6774e-06 2 3.6774e-06 -0.017 9.7290e-07 9.7290e-07 2.7045e-06
transfer 3 SWV 4 1145.3333 -0.330 i2 3.5755e-06 2 3.5755e-06 -0.059 9.0010e-07 9.0010e-07 2.6753e-06
transfer 3 SWV 5 1148.0500 -0.324 i2 3.3699e-06 2 3.3699e-06 -0.007 9.0400e-07 9.0400e-07 2.4659e-06
transfer 3 SWV 6 1151.1167 -0.322 i2 3.2455e-06 2 3.2455e-06 -0.028 9.0890e-07 9.0890e-07 2.3365e-06
transfer 3 SWV 7 1153.8500 -0.318 i2 3.1531e-06 2 3.1531e-06 -0.047 9.4640e-07 9.4640e-07 2.2067e-06
transfer 3 SWV 8 1156.6833 -0.340 i2 3.0887e-06 2 3.0887e-06 -0.070 9.2910e-07 9.2910e-07 2.1596e-06
control transfer 0 NA 890.3500 -0.400 i2 8.4660e-07 2 8.4660e-07 -0.018 6.2330e-07 6.2330e-07 2.2330e-07


Here we will plot all of the transfer SWV data with the min/max points we found:

ggplot(swv_data %>% filter(electrode == 'i1' & reactor == 'transfer'), aes(x = E , y = current )) +
  geom_path(aes(group = rep, color = rep)) + facet_wrap(exp~run, scales = 'free') + 
  geom_point(data = swv_signals %>% filter(electrode == 'i1' & reactor == 'transfer'), aes(x = E_from_mins, y = current_from_mins), shape = 21, fill = 'light blue') + 
  geom_point(data = swv_signals %>% filter(electrode == 'i1' & reactor == 'transfer'), aes(x = E_from_maxs, y = current_from_maxs), shape = 21, fill = 'red')

The function we used above echem_signal() went ahead and quantified the difference between the max and min points. We called this value signal, and it effectively background subtracts the peak current from any persistent background current. We also quantified the peak currents for the soak reactor, before the biofilms were transferred, so we will plot those values on top. Let’s see how the signal decays over the acquired scans:

ggplot(data = swv_signals %>% filter(electrode == 'i1' & reactor == 'transfer'), aes(x = rep, y = signal, color = factor(run), fill =factor(run))) + 
  geom_point(data = swv_signals %>% filter(electrode == 'i1' & reactor == 'soak'), size = 3)+
  geom_line() + 
  geom_point(shape = 21, color = 'black') +
  facet_wrap(~exp)

GC

Let’s repeat a similar process for the GC data. First we will quantify using echem_signal(). For GC data we only take the last point (~ -0.4V), since that point is the closest in time to the following SWV. Later we will pair these datasets, so that’s important.

gc_data <- bind_rows(gc_data_1, gc_data_2)  

unique_id_cols = c('reactor','run','echem','rep','rep','minutes','electrode', 'exp')

gc_signals <- echem_signal(df = gc_data %>% filter(electrode == 'i2') %>% mutate(current = - current), 
                            unique_id_cols = unique_id_cols,
                            max_interval = c(-0.399,-0.399), 
                            min_interval = c(0.0,-0.4))

Now we can plot the GC scans and the min / max points.

ggplot(gc_data %>% filter(reactor == 'transfer')) + 
  geom_path(data=. %>% filter(electrode=='i1'), aes(x = E, y = current, color = rep, group = rep)) + 
  geom_path(data=. %>% filter(electrode=='i2'), aes(x = E, y = current, color = rep, group = rep)) +
  geom_point(data = gc_signals %>% filter(reactor == 'transfer'), aes(x = E_from_mins, y = -current_from_mins), shape = 21, fill = 'light blue')+
  geom_point(data = gc_signals %>% filter(reactor == 'transfer'), aes(x = E_from_maxs, y = -current_from_maxs), shape = 21, fill = 'red')+
  scale_x_reverse() + facet_wrap(exp~run)

Note we always quantify from the negative collector current. Now, let’s look at the background subtracted GC peak currents over time:

ggplot(data = gc_signals %>% filter(reactor == 'transfer'), aes(x = rep, y = signal, color = factor(run), fill =factor(run) )) + 
  geom_line() + 
  geom_point(shape = 21, color = 'black') +
  facet_wrap(~exp)

Timing and matching SWV / GC

The last thing we need to do is convert rep into a time. The function echem_import_to_df() actually read the first line of each file that contains a date and time stamp and converted it into minutes, which is a variable that we have carried through up to this point.

We will simply find the minimum time within each run (e.g. technical replicate) and then subtract that value from all the minutes values. Let’s vizualize the acquisition of the SWVs and GCs together:

df_signals <- bind_rows(swv_signals %>% filter(electrode == 'i1'), gc_signals) %>% 
  group_by(reactor, run, exp) %>% 
  mutate(min_time = min(minutes)) %>% 
  mutate(time = minutes - min_time + 0.5)
  
# add 30 seconds to account for transfer time

ggplot(df_signals %>% filter(reactor == 'transfer'), 
       aes(x = time, y = echem, color = time, fill = time, shape = echem)) + 
  geom_line(aes(group = run))+geom_point(color = 'black') + 
  facet_wrap(exp~run) +scale_shape_manual(values = c(21,22))

The timestamps are generated when each file is saved (immediately following acquisition), so the long diagonals in time are the relatively slow GC acquisitions (~3min) which are followed by almost vertical lines, because of the relatively short SWV acquisitions (~5 seconds). This pattern looks perfect as if it were generated by a computer, but these scans were actually taken manually. We can see this by looking at one acquisitions rep # vs. time:

ggplot(df_signals %>% filter(reactor == 'transfer' & exp == 1 & run ==1), 
       aes(x = rep, y =time, color = echem, group = run)) + 
  geom_smooth(method = 'lm', se = F, color = 'black')+geom_point(shape =21, size = 4, stroke = 1 ) + facet_wrap(exp~run)

You can see that the blue SWV circles are always slightly above the orange GC dots in time, but there are very slight differences in the acquisition intervals.

Now that we can see the GC and SWV match very well in time by rep, we can go ahead and join the SWV and GC signals by rep so that we can actually plot those values against each other. This will be used in downstream analysis:

df_swv_gc <- left_join(df_signals %>% filter(echem == 'SWV'), df_signals %>% filter(echem == 'GC'),
                       by = c('reactor','exp','run','rep'), suffix = c('_SWV','_GC'))

ggplot(data = df_swv_gc %>% filter(reactor == 'transfer' & rep >0), 
       aes(x = signal_SWV, y = signal_GC, linetype = factor(run), fill = rep)) + 
  geom_line() + geom_point(shape = 21, color = 'black') +
  facet_wrap(~exp, scales = 'free')


Output

Let’s write our swv and gc signal dataframes to csv files to be used for further analysis.

write_csv(df_signals, "../processed_data/phz_eDNA_2019_signals_long.csv")

write_csv(df_swv_gc, "../processed_data/phz_eDNA_2019_swv_gc_signals.csv")

Let’s also write the raw data from the first biofilm, first technical replicate transfer to use as representative data in figure 6.

write_csv(swv_data %>% filter(exp == 1, run ==1, reactor == 'transfer', electrode == 'i1'), "../processed_data/phz_eDNA_2019_swv_raw_1_1.csv")

write_csv(gc_data %>% filter(exp == 1, run ==1, reactor == 'transfer'), "../processed_data/phz_eDNA_2019_gc_raw_1_1.csv")

sessionInfo()
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.6
## 
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] lubridate_1.7.4   hms_0.4.2         viridis_0.5.1    
##  [4] viridisLite_0.3.0 kableExtra_1.1.0  cowplot_0.9.4    
##  [7] forcats_0.4.0     stringr_1.4.0     dplyr_0.8.1      
## [10] purrr_0.3.2       readr_1.3.1       tidyr_0.8.3      
## [13] tibble_2.1.3      ggplot2_3.2.1     tidyverse_1.2.1  
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_0.2.5 xfun_0.7         haven_2.1.0      lattice_0.20-38 
##  [5] colorspace_1.4-1 generics_0.0.2   htmltools_0.3.6  yaml_2.2.0      
##  [9] rlang_0.4.0      pillar_1.4.2     glue_1.3.1       withr_2.1.2     
## [13] modelr_0.1.4     readxl_1.3.1     munsell_0.5.0    gtable_0.3.0    
## [17] cellranger_1.1.0 rvest_0.3.4      evaluate_0.14    labeling_0.3    
## [21] knitr_1.23       highr_0.8        broom_0.5.2      Rcpp_1.0.2      
## [25] scales_1.0.0     backports_1.1.4  webshot_0.5.1    jsonlite_1.6    
## [29] gridExtra_2.3    digest_0.6.21    stringi_1.4.3    grid_3.5.3      
## [33] cli_1.1.0        tools_3.5.3      magrittr_1.5     lazyeval_0.2.2  
## [37] crayon_1.3.4     pkgconfig_2.0.3  xml2_1.2.0       assertthat_0.2.1
## [41] rmarkdown_1.13   httr_1.4.0       rstudioapi_0.10  R6_2.4.0        
## [45] nlme_3.1-137     compiler_3.5.3